Exemplo n.º 1
0
 public bool Equals(Quaternion other)
 {
     return Math.Abs(other.X - X) < float.Epsilon &&
         Math.Abs(other.Y - Y) < float.Epsilon &&
         Math.Abs(other.Z - Z) < float.Epsilon &&
         Math.Abs(other.W - W) < float.Epsilon;
 }
Exemplo n.º 2
0
        public void TestToString()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            var quat = new Quaternion(1.1f, 2.0f, 0f, 4.0f);

            Assert.AreEqual("X: 1.1 Y: 2 Z: 0 W: 4", quat.ToString());
        }
Exemplo n.º 3
0
        public void TestGetHashCode()
        {
            var quat1 = new Quaternion(1.1f, 2.0f, 0f, 4.0f);
            var quat15 = new Quaternion(1.1f, 2.0f, 0f, 4.0f);
            var quat2 = new Quaternion(1.1f, 2.0f, 0.0001f, 4.0f);

            Assert.AreEqual(quat1.GetHashCode(), quat15.GetHashCode());
            Assert.AreNotEqual(quat1.GetHashCode(), quat2.GetHashCode());
        }
Exemplo n.º 4
0
 public void TestConstructor()
 {
     var quat = new Quaternion(1.0f, 2.0f, 3.0f, 4.0f);
     Assert.IsNotNull(quat);
     Assert.AreEqual(1.0f, quat.X);
     Assert.AreEqual(2.0f, quat.Y);
     Assert.AreEqual(3.0f, quat.Z);
     Assert.AreEqual(4.0f, quat.W);
 }
Exemplo n.º 5
0
        public void TestEquals()
        {
            var quat1 = new Quaternion(1.1f, 2.0f, 0f, 4.0f);
            var quat15 = new Quaternion(1.1f, 2.0f, 0f, 4.0f);
            var quat2 = new Quaternion(1.1f, 2.0f, 3.0f, 4.0f);

            Assert.IsTrue(quat1.Equals(quat15));
            Assert.IsTrue(quat1.Equals(quat1));
            Assert.IsFalse(quat1.Equals(quat2));
        }
Exemplo n.º 6
0
        public void TestOperators()
        {
            var quat1 = new Quaternion(1.1f, 2.0f, 0f, 4.0f);
            var quat15 = new Quaternion(1.1f, 2.0f, 0f, 4.0f);
            var quat2 = new Quaternion(1.1f, 2.0f, 3.0f, 4.0f);

            Assert.IsTrue(quat1 == quat15);
            #pragma warning disable 1718
            // ReSharper disable once EqualExpressionComparison
            Assert.IsTrue(quat1 == quat1);
            #pragma warning restore 1718
            Assert.IsFalse(quat1 == quat2);
        }