Ejemplo n.º 1
0
 /// <summary>
 /// copy constructor
 /// </summary>
 public bquat(bquat 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 bquat result)
        {
            result = Zero;
            if (string.IsNullOrEmpty(s))
            {
                return(false);
            }
            var kvp = s.Split(new[] { sep }, StringSplitOptions.None);

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

            result = ok ? new bquat(x, y, z, w) : Zero;
            return(ok);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Returns a bquat from component-wise application of Or (lhs || rhs).
 /// </summary>
 public static bquat Or(bquat lhs, bquat rhs) => bquat.Or(lhs, rhs);
Ejemplo n.º 4
0
 /// <summary>
 /// Returns a bquat from component-wise application of Xnor (lhs == rhs).
 /// </summary>
 public static bquat Xnor(bool lhs, bquat rhs) => new bquat(lhs == rhs.x, lhs == rhs.y, lhs == rhs.z, lhs == rhs.w);
Ejemplo n.º 5
0
 /// <summary>
 /// Returns a bquat from component-wise application of Xnor (lhs == rhs).
 /// </summary>
 public static bquat Xnor(bquat lhs, bquat rhs) => new bquat(lhs.x == rhs.x, lhs.y == rhs.y, lhs.z == rhs.z, lhs.w == rhs.w);
Ejemplo n.º 6
0
 /// <summary>
 /// Returns a bquat from component-wise application of Xor (lhs != rhs).
 /// </summary>
 public static bquat Xor(bquat lhs, bquat rhs) => new bquat(lhs.x != rhs.x, lhs.y != rhs.y, lhs.z != rhs.z, lhs.w != rhs.w);
Ejemplo n.º 7
0
 /// <summary>
 /// Returns a bquat from component-wise application of Nor (!(lhs || rhs)).
 /// </summary>
 public static bquat Nor(bquat lhs, bool rhs) => new bquat(!(lhs.x || rhs), !(lhs.y || rhs), !(lhs.z || rhs), !(lhs.w || rhs));
Ejemplo n.º 8
0
 /// <summary>
 /// Returns a bquat from component-wise application of Or (lhs || rhs).
 /// </summary>
 public static bquat Or(bool lhs, bquat rhs) => new bquat(lhs || rhs.x, lhs || rhs.y, lhs || rhs.z, lhs || rhs.w);
Ejemplo n.º 9
0
 /// <summary>
 /// Returns a bquat from component-wise application of Or (lhs || rhs).
 /// </summary>
 public static bquat Or(bquat lhs, bquat rhs) => new bquat(lhs.x || rhs.x, lhs.y || rhs.y, lhs.z || rhs.z, lhs.w || rhs.w);
Ejemplo n.º 10
0
 /// <summary>
 /// Returns a bvec4 from component-wise application of NotEqual (lhs != rhs).
 /// </summary>
 public static bvec4 NotEqual(bquat lhs, bquat rhs) => new bvec4(lhs.x != rhs.x, lhs.y != rhs.y, lhs.z != rhs.z, lhs.w != rhs.w);
Ejemplo n.º 11
0
 /// <summary>
 /// Returns a bvec4 from component-wise application of Equal (lhs == rhs).
 /// </summary>
 public static bvec4 Equal(bquat lhs, bool rhs) => new bvec4(lhs.x == rhs, lhs.y == rhs, lhs.z == rhs, lhs.w == rhs);
Ejemplo n.º 12
0
 /// <summary>
 /// Returns a bvec4 from component-wise application of Equal (lhs == rhs).
 /// </summary>
 public static bvec4 Equal(bquat lhs, bquat rhs) => new bvec4(lhs.x == rhs.x, lhs.y == rhs.y, lhs.z == rhs.z, lhs.w == rhs.w);
Ejemplo n.º 13
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 bquat result) => TryParse(s, ", ", out result);
Ejemplo n.º 14
0
 /// <summary>
 /// Returns true iff this equals rhs component-wise.
 /// </summary>
 public bool Equals(bquat rhs) => ((x.Equals(rhs.x) && y.Equals(rhs.y)) && (z.Equals(rhs.z) && w.Equals(rhs.w)));
Ejemplo n.º 15
0
 /// <summary>
 /// Returns a bquat from component-wise application of Nor (!(lhs || rhs)).
 /// </summary>
 public static bquat Nor(bquat lhs, bquat rhs) => bquat.Nor(lhs, rhs);
Ejemplo n.º 16
0
 /// <summary>
 /// Returns a bquat from component-wise application of Nand (!(lhs &amp;&amp; rhs)).
 /// </summary>
 public static bquat Nand(bquat lhs, bool rhs) => new bquat(!(lhs.x && rhs), !(lhs.y && rhs), !(lhs.z && rhs), !(lhs.w && rhs));
Ejemplo n.º 17
0
 /// <summary>
 /// Returns a bquat from component-wise application of Nand (!(lhs &amp;&amp; rhs)).
 /// </summary>
 public static bquat Nand(bool lhs, bquat rhs) => new bquat(!(lhs && rhs.x), !(lhs && rhs.y), !(lhs && rhs.z), !(lhs && rhs.w));
Ejemplo n.º 18
0
 /// <summary>
 /// Returns a bvec4 from component-wise application of NotEqual (lhs != rhs).
 /// </summary>
 public static bvec4 NotEqual(bquat lhs, bool rhs) => new bvec4(lhs.x != rhs, lhs.y != rhs, lhs.z != rhs, lhs.w != rhs);
Ejemplo n.º 19
0
 /// <summary>
 /// Returns a bquat from component-wise application of Or (lhs || rhs).
 /// </summary>
 public static bquat Or(bquat lhs, bool rhs) => new bquat(lhs.x || rhs, lhs.y || rhs, lhs.z || rhs, lhs.w || rhs);
Ejemplo n.º 20
0
 /// <summary>
 /// Returns a bvec4 from component-wise application of NotEqual (lhs != rhs).
 /// </summary>
 public static bvec4 NotEqual(bool lhs, bquat rhs) => new bvec4(lhs != rhs.x, lhs != rhs.y, lhs != rhs.z, lhs != rhs.w);
Ejemplo n.º 21
0
 /// <summary>
 /// Returns a bquat from component-wise application of Nor (!(lhs || rhs)).
 /// </summary>
 public static bquat Nor(bquat lhs, bquat rhs) => new bquat(!(lhs.x || rhs.x), !(lhs.y || rhs.y), !(lhs.z || rhs.z), !(lhs.w || rhs.w));
Ejemplo n.º 22
0
 /// <summary>
 /// Returns a bvec4 from component-wise application of Not (!v).
 /// </summary>
 public static bvec4 Not(bquat v) => new bvec4(!v.x, !v.y, !v.z, !v.w);
Ejemplo n.º 23
0
 /// <summary>
 /// Returns a bquat from component-wise application of Nor (!(lhs || rhs)).
 /// </summary>
 public static bquat Nor(bool lhs, bquat rhs) => new bquat(!(lhs || rhs.x), !(lhs || rhs.y), !(lhs || rhs.z), !(lhs || rhs.w));
Ejemplo n.º 24
0
 /// <summary>
 /// Returns a bquat from component-wise application of And (lhs &amp;&amp; rhs).
 /// </summary>
 public static bquat And(bquat lhs, bquat rhs) => new bquat(lhs.x && rhs.x, lhs.y && rhs.y, lhs.z && rhs.z, lhs.w && rhs.w);
Ejemplo n.º 25
0
 /// <summary>
 /// Returns a bquat from component-wise application of Xor (lhs != rhs).
 /// </summary>
 public static bquat Xor(bquat lhs, bool rhs) => new bquat(lhs.x != rhs, lhs.y != rhs, lhs.z != rhs, lhs.w != rhs);
Ejemplo n.º 26
0
 /// <summary>
 /// Returns a bquat from component-wise application of And (lhs &amp;&amp; rhs).
 /// </summary>
 public static bquat And(bquat lhs, bool rhs) => new bquat(lhs.x && rhs, lhs.y && rhs, lhs.z && rhs, lhs.w && rhs);
Ejemplo n.º 27
0
 /// <summary>
 /// Returns a bquat from component-wise application of Xnor (lhs == rhs).
 /// </summary>
 public static bquat Xnor(bquat lhs, bool rhs) => new bquat(lhs.x == rhs, lhs.y == rhs, lhs.z == rhs, lhs.w == rhs);
Ejemplo n.º 28
0
 /// <summary>
 /// Returns a bquat from component-wise application of And (lhs &amp;&amp; rhs).
 /// </summary>
 public static bquat And(bool lhs, bquat rhs) => new bquat(lhs && rhs.x, lhs && rhs.y, lhs && rhs.z, lhs && rhs.w);
Ejemplo n.º 29
0
 /// <summary>
 /// Returns a bquat from component-wise application of Nand (!(lhs &amp;&amp; rhs)).
 /// </summary>
 public static bquat Nand(bquat lhs, bquat rhs) => new bquat(!(lhs.x && rhs.x), !(lhs.y && rhs.y), !(lhs.z && rhs.z), !(lhs.w && rhs.w));
Ejemplo n.º 30
0
 /// <summary>
 /// Returns a bquat from component-wise application of Nand (!(lhs &amp;&amp; rhs)).
 /// </summary>
 public static bquat Nand(bquat lhs, bquat rhs) => bquat.Nand(lhs, rhs);