Ejemplo n.º 1
0
        public void Equals()
        {
            var mat1 = new SFMatrix3d();
            var mat2 = new SFMatrix3d();

            Assert.AreEqual(mat1, mat2);

            var test = new SFDouble[, ] {
                { 1, 1, 1 }, { 0, 0, 0 }, { -1, -1, -1 }
            };

            mat1 = new SFMatrix3d(test);
            mat2 = new SFMatrix3d(test);

            Assert.AreEqual(mat1.GetHashCode(), mat2.GetHashCode());

            var a = new SFMatrix3d();
            var c = new SFMatrix4d();
            var t = new SFDouble[, ] {
                { 1, 1, 1 }, { 0, 0, 0 }, { -1, -1, -1 }
            };
            var b = new SFMatrix3d(test);

            Assert.AreNotEqual(a, b);
            Assert.AreNotEqual(a, t);
            Assert.AreNotEqual(a, c);
        }
Ejemplo n.º 2
0
        public void StringCompatibility()
        {
            var a = new SFDouble();
            var b = new SFDouble(123456.12345678901234);

            Assert.AreEqual(a.ToString(), 0.0.ToString(CultureInfo.InvariantCulture));
            Assert.AreEqual(b.ToString(), 123456.12345678901234.ToString(CultureInfo.InvariantCulture));
        }
Ejemplo n.º 3
0
        public void HashCode()
        {
            var a = new SFDouble();
            var b = new SFDouble(123456.12345678901234);

            Assert.AreEqual(a.GetHashCode(), 0.0.GetHashCode());
            Assert.AreEqual(b.GetHashCode(), 123456.12345678901234.GetHashCode());
        }
Ejemplo n.º 4
0
        public void Constructors()
        {
            var mat = new SFMatrix4d();

            Assert.IsTrue(Math.Abs(mat.Elements[0, 0] - 1) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[0, 1] - 0) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[0, 2] - 0) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[0, 3] - 0) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[1, 0] - 0) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[1, 1] - 1) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[1, 2] - 0) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[1, 3] - 0) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[2, 0] - 0) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[2, 1] - 0) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[2, 2] - 1) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[2, 3] - 0) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[3, 0] - 0) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[3, 1] - 0) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[3, 2] - 0) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[3, 3] - 1) < EPSILON);

            var elements = new SFDouble[, ] {
                { 1, 1, 1, 1 }, { 0, 0, 0, 0 }, { -1, -1, -1, -1 }, { 0, 0, 0, 0 }
            };

            mat = new SFMatrix4d(elements);

            Assert.IsTrue(Math.Abs(mat.Elements[0, 0] - 1) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[0, 1] - 1) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[0, 2] - 1) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[0, 3] - 1) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[1, 0] - 0) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[1, 1] - 0) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[1, 2] - 0) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[1, 3] - 0) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[2, 0] + 1) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[2, 1] + 1) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[2, 2] + 1) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[2, 3] + 1) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[3, 0] - 0) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[3, 1] - 0) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[3, 2] - 0) < EPSILON);
            Assert.IsTrue(Math.Abs(mat.Elements[3, 3] - 0) < EPSILON);

            try
            {
                var element = new SFDouble[, ] {
                    { 1 }, { 0 }
                };
                new SFMatrix4d(element);
                Assert.Fail();
            }
            catch (ArgumentException)
            {
            }
        }
Ejemplo n.º 5
0
        public void DoubleCasting()
        {
            var      a = new SFDouble();
            double   v = a;
            SFDouble w = v;

            Assert.IsTrue(Math.Abs(a - v) < 0.000000000000001);
            Assert.IsTrue(Math.Abs(v - w) < 0.000000000000001);
            Assert.AreEqual(w, a);
        }
Ejemplo n.º 6
0
        public void DoubleCompatibility()
        {
            var a = new SFDouble();
            var b = new SFDouble(a);
            var c = new SFDouble(123456.12345678901234);

            Assert.IsTrue(0 == a);
            Assert.IsTrue(b == 0);
            Assert.IsTrue(Math.Abs(123456.12345678901234 - c) < 0.000000000000001);
        }
Ejemplo n.º 7
0
        public void Constructor()
        {
            var a = new SFDouble();
            var b = new SFDouble(a);
            var c = new SFDouble(123456.12345678901234);

            Assert.AreEqual(a, 0);
            Assert.AreEqual(b, a);
            Assert.AreEqual(c, 123456.12345678901234);
            Assert.AreNotEqual(c, true);
        }
Ejemplo n.º 8
0
        public void HashCode()
        {
            var mat1 = new SFMatrix3d();
            var mat2 = new SFMatrix3d();

            Assert.AreEqual(mat1.GetHashCode(), mat2.GetHashCode());

            var test = new SFDouble[, ] {
                { 1, 1, 1 }, { 0, 0, 0 }, { -1, -1, -1 }
            };

            mat1 = new SFMatrix3d(test);
            mat2 = new SFMatrix3d(test);

            Assert.AreEqual(mat1.GetHashCode(), mat2.GetHashCode());
        }
Ejemplo n.º 9
0
 public SFDouble(SFDouble obj)
 {
     this.Primitive = obj.Primitive;
 }