Ejemplo n.º 1
0
 /// <summary>
 /// copy constructor
 /// </summary>
 public qint(qint q)
 {
     this.x = q.x;
     this.y = q.y;
     this.z = q.z;
     this.w = q.w;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Tries to convert the string representation of the quaternion into a quaternion representation (using a designated separator), returns false if string was invalid.
        /// </summary>
        public static bool TryParse(string s, string sep, out qint result)
        {
            result = Zero;
            if (string.IsNullOrEmpty(s))
            {
                return(false);
            }
            var kvp = s.Split(new[] { sep }, StringSplitOptions.None);

            if (kvp.Length != 4)
            {
                return(false);
            }
            int x = 0, y = 0, z = 0, w = 0;
            var ok = ((int.TryParse(kvp[0].Trim(), out x) && int.TryParse(kvp[1].Trim(), out y)) && (int.TryParse(kvp[2].Trim(), out z) && int.TryParse(kvp[3].Trim(), out w)));

            result = ok ? new qint(x, y, z, w) : Zero;
            return(ok);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Returns a bool4 from component-wise application of NotEqual (lhs != rhs).
 /// </summary>
 public static bool4 NotEqual(qint lhs, int rhs) => new bool4(lhs.x != rhs, lhs.y != rhs, lhs.z != rhs, lhs.w != rhs);
Ejemplo n.º 4
0
 /// <summary>
 /// Returns a string representation of this quaternion using a provided seperator and a format for each component.
 /// </summary>
 public static string ToString(qint q, string sep, string format) => q.ToString(sep, format);
Ejemplo n.º 5
0
 /// <summary>
 /// Returns a bool4 from component-wise application of Equal (lhs == rhs).
 /// </summary>
 public static bool4 Equal(qint lhs, int rhs) => new bool4(lhs.x == rhs, lhs.y == rhs, lhs.z == rhs, lhs.w == rhs);
Ejemplo n.º 6
0
 /// <summary>
 /// Returns a bool4 from component-wise application of LesserThanEqual (lhs &lt;= rhs).
 /// </summary>
 public static bool4 LesserThanEqual(int lhs, qint rhs) => new bool4(lhs <= rhs.x, lhs <= rhs.y, lhs <= rhs.z, lhs <= rhs.w);
Ejemplo n.º 7
0
 /// <summary>
 /// Returns the number of components (4).
 /// </summary>
 public static int Count(qint q) => q.Count;
Ejemplo n.º 8
0
 /// <summary>
 /// Returns a bool4 from component-wise application of GreaterThanEqual (lhs &gt;= rhs).
 /// </summary>
 public static bool4 GreaterThanEqual(qint lhs, int rhs) => new bool4(lhs.x >= rhs, lhs.y >= rhs, lhs.z >= rhs, lhs.w >= rhs);
Ejemplo n.º 9
0
 /// <summary>
 /// Returns a bool4 from component-wise application of LesserThan (lhs &lt; rhs).
 /// </summary>
 public static bool4 LesserThan(qint lhs, int rhs) => new bool4(lhs.x < rhs, lhs.y < rhs, lhs.z < rhs, lhs.w < rhs);
Ejemplo n.º 10
0
 /// <summary>
 /// Returns a bool4 from component-wise application of GreaterThanEqual (lhs &gt;= rhs).
 /// </summary>
 public static bool4 GreaterThanEqual(qint lhs, qint rhs) => qint.GreaterThanEqual(lhs, rhs);
Ejemplo n.º 11
0
 /// <summary>
 /// Returns a bool4 from component-wise application of LesserThan (lhs &lt; rhs).
 /// </summary>
 public static bool4 LesserThan(qint lhs, qint rhs) => qint.LesserThan(lhs, rhs);
Ejemplo n.º 12
0
 /// <summary>
 /// Returns a bool4 from component-wise application of Equal (lhs == rhs).
 /// </summary>
 public static bool4 Equal(qint lhs, qint rhs) => qint.Equal(lhs, rhs);
Ejemplo n.º 13
0
 /// <summary>
 /// Returns a bool4 from component-wise application of NotEqual (lhs != rhs).
 /// </summary>
 public static bool4 NotEqual(qint lhs, qint rhs) => qint.NotEqual(lhs, rhs);
Ejemplo n.º 14
0
 /// <summary>
 /// Returns a hash code for this instance.
 /// </summary>
 public static int GetHashCode(qint q) => q.GetHashCode();
Ejemplo n.º 15
0
 /// <summary>
 /// Returns true iff this equals rhs type- and component-wise.
 /// </summary>
 public static bool Equals(qint q, object obj) => q.Equals(obj);
Ejemplo n.º 16
0
 /// <summary>
 /// Returns true iff this equals rhs component-wise.
 /// </summary>
 public static bool Equals(qint q, qint rhs) => q.Equals(rhs);
Ejemplo n.º 17
0
 /// <summary>
 /// Returns a bool4 from component-wise application of NotEqual (lhs != rhs).
 /// </summary>
 public static bool4 NotEqual(int lhs, qint rhs) => new bool4(lhs != rhs.x, lhs != rhs.y, lhs != rhs.z, lhs != rhs.w);
Ejemplo n.º 18
0
 /// <summary>
 /// Returns true iff this equals rhs component-wise.
 /// </summary>
 public bool Equals(qint rhs) => ((x.Equals(rhs.x) && y.Equals(rhs.y)) && (z.Equals(rhs.z) && w.Equals(rhs.w)));
Ejemplo n.º 19
0
 /// <summary>
 /// Returns a bool4 from component-wise application of GreaterThan (lhs &gt; rhs).
 /// </summary>
 public static bool4 GreaterThan(qint lhs, int rhs) => new bool4(lhs.x > rhs, lhs.y > rhs, lhs.z > rhs, lhs.w > rhs);
Ejemplo n.º 20
0
 /// <summary>
 /// Tries to convert the string representation of the quaternion into a quaternion representation (using ', ' as a separator), returns false if string was invalid.
 /// </summary>
 public static bool TryParse(string s, out qint result) => TryParse(s, ", ", out result);
Ejemplo n.º 21
0
 /// <summary>
 /// Returns a bool4 from component-wise application of GreaterThanEqual (lhs &gt;= rhs).
 /// </summary>
 public static bool4 GreaterThanEqual(int lhs, qint rhs) => new bool4(lhs >= rhs.x, lhs >= rhs.y, lhs >= rhs.z, lhs >= rhs.w);
Ejemplo n.º 22
0
 /// <summary>
 /// Returns a qint from component-wise application of Lerp (min * (1-a) + max * a).
 /// </summary>
 public static qint Lerp(qint min, int max, int a) => new qint(min.x * (1 - a) + max * a, min.y * (1 - a) + max * a, min.z * (1 - a) + max * a, min.w * (1 - a) + max * a);
Ejemplo n.º 23
0
 /// <summary>
 /// Returns a bool4 from component-wise application of LesserThanEqual (lhs &lt;= rhs).
 /// </summary>
 public static bool4 LesserThanEqual(qint lhs, int rhs) => new bool4(lhs.x <= rhs, lhs.y <= rhs, lhs.z <= rhs, lhs.w <= rhs);
Ejemplo n.º 24
0
 /// <summary>
 /// Returns a qint from component-wise application of Lerp (min * (1-a) + max * a).
 /// </summary>
 public static qint Lerp(int min, int max, qint a) => new qint(min * (1 - a.x) + max * a.x, min * (1 - a.y) + max * a.y, min * (1 - a.z) + max * a.z, min * (1 - a.w) + max * a.w);
Ejemplo n.º 25
0
 /// <summary>
 /// Returns a qint from component-wise application of Lerp (min * (1-a) + max * a).
 /// </summary>
 public static qint Lerp(qint min, int max, qint a) => new qint(min.x * (1 - a.x) + max * a.x, min.y * (1 - a.y) + max * a.y, min.z * (1 - a.z) + max * a.z, min.w * (1 - a.w) + max * a.w);
Ejemplo n.º 26
0
 /// <summary>
 /// Returns a string representation of this quaternion using a provided seperator and a format and format provider for each component.
 /// </summary>
 public static string ToString(qint q, string sep, string format, IFormatProvider provider) => q.ToString(sep, format, provider);
Ejemplo n.º 27
0
 /// <summary>
 /// Returns a qint from component-wise application of Lerp (min * (1-a) + max * a).
 /// </summary>
 public static qint Lerp(int min, qint max, int a) => new qint(min * (1 - a) + max.x * a, min * (1 - a) + max.y * a, min * (1 - a) + max.z * a, min * (1 - a) + max.w * a);
Ejemplo n.º 28
0
 /// <summary>
 /// Returns the inner product (dot product, scalar product) of the two quaternions.
 /// </summary>
 public static int Dot(qint lhs, qint rhs) => ((lhs.x * rhs.x + lhs.y * rhs.y) + (lhs.z * rhs.z + lhs.w * rhs.w));
Ejemplo n.º 29
0
 /// <summary>
 /// Returns the cross product between two quaternions.
 /// </summary>
 public static qint Cross(qint q1, qint q2) => new qint(q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y, q1.w * q2.y + q1.y * q2.w + q1.z * q2.x - q1.x * q2.z, q1.w * q2.z + q1.z * q2.w + q1.x * q2.y - q1.y * q2.x, q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z);
Ejemplo n.º 30
0
 /// <summary>
 /// Returns a string representation of this quaternion using a provided seperator.
 /// </summary>
 public static string ToString(qint q, string sep) => q.ToString(sep);