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); }
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)); }
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()); }
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) { } }
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); }
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); }
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); }
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()); }
public SFDouble(SFDouble obj) { this.Primitive = obj.Primitive; }