public static void TestAngleTo() { // Prepare test Tuple3dc a = new Tuple3dc(1, 2, 3); Tuple3dc b = new Tuple3dc(4, 5, 6); double angle = a.AngleTo(b); // Execute test Assert.AreEqual(0.225726128552734, angle, delta); }
public static void TestBinaryOperatorDistance() { // Prepare test Tuple3dc a = new Tuple3dc(1, 2, 3); Tuple3dc b = new Tuple3dc(4, 5, 6); double c = a % b; // Execute test Assert.AreEqual(5.19615242270663, c, delta); }
public static void TestBinaryOperatorCrossProductWithITuple() { // Prepare test Tuple3dc a = new Tuple3dc(1, 2, 3); ITuple b = new Tuple3dc(4, 5, 6); Tuple3dc c = a ^ b; // Execute test Assert.AreEqual(-3, c.x, delta); Assert.AreEqual(6, c.y, delta); Assert.AreEqual(-3, c.z, delta); }
public static void TestToTuple3ds() { // Prepare test Tuple3dc tuple3dc = new Tuple3dc(1.1, 2.2, 3.5); Tuple3ds tuple3ds = new Tuple3ds(1.1, 2.2, 3.5); Tuple3ds fromTuple3dc = tuple3dc.ToTuple3ds(); Tuple3ds fromTuple3ds = tuple3ds.ToTuple3ds(); // Execute test Assert.AreEqual(1.1, fromTuple3dc.x, delta); Assert.AreEqual(2.2, fromTuple3dc.y, delta); Assert.AreEqual(3.5, fromTuple3dc.z, delta); Assert.AreEqual(1.1, fromTuple3ds.x, delta); Assert.AreEqual(2.2, fromTuple3ds.y, delta); Assert.AreEqual(3.5, fromTuple3ds.z, delta); }
public static void TestBinaryOperatorPlusWithITuple() { // Prepare test Tuple3dc a = new Tuple3dc(1, 2, 3); ITuple b = new Tuple3dc(4, 5, 6); Tuple3dc c = a + b; // Execute test Assert.AreEqual(5, c.x, delta); Assert.AreEqual(7, c.y, delta); Assert.AreEqual(9, c.z, delta); }
public static void TestBinaryOperatorScale() { // Prepare test Tuple3dc a = new Tuple3dc(1, 2, 3); Tuple3dc b = a * 4.7; // Execute test Assert.AreEqual(4.7, b.x, delta); Assert.AreEqual(9.4, b.y, delta); Assert.AreEqual(14.1, b.z, delta); }
public void GetColumns(out Tuple3dc c0, out Tuple3dc c1, out Tuple3dc c2) { c0 = new Tuple3dc(M00, M10, M20); c1 = new Tuple3dc(M01, M11, M21); c2 = new Tuple3dc(M02, M12, M22); }
public static void TestBinaryOperatorMinus() { // Prepare test Tuple3dc a = new Tuple3dc(1, 2, 3); Tuple3dc b = new Tuple3dc(4, 5, 6); Tuple3dc c = a - b; // Execute test Assert.AreEqual(-3, c.x, delta); Assert.AreEqual(-3, c.y, delta); Assert.AreEqual(-3, c.z, delta); }
public static void TestUnaryOperatorNormalize() { // Prepare test Tuple3dc tuple = new Tuple3dc(1, 2, 3); Tuple3dc normalizedTuple = ~tuple; // Execute test Assert.AreEqual(0.267261241912424, normalizedTuple.x, delta); Assert.AreEqual(0.534522483824849, normalizedTuple.y, delta); Assert.AreEqual(0.801783725737273, normalizedTuple.z, delta); }
public Matrix3d SetColumns(Tuple3dc c0, Tuple3dc c1, Tuple3dc c2) { M00 = c0.x; M01 = c1.x; M02 = c2.x; M10 = c0.y; M11 = c1.y; M12 = c2.y; M20 = c0.z; M21 = c1.z; M22 = c2.z; return this; }
public Matrix4d SetScale(Tuple3dc tuple) { M01 = M02 = M03 = 0; M10 = M12 = M13 = 0; M20 = M21 = M23 = 0; M30 = M31 = M32 = 0; M00 = tuple.x; M11 = tuple.y; M22 = tuple.z; M33 = 1; return this; }
public Matrix3d SetRow(Tuple3dc t, int r) { if (r == 0) { M00 = t.x; M01 = t.y; M02 = t.z; } if (r == 1) { M10 = t.x; M11 = t.y; M12 = t.z; } if (r == 2) { M20 = t.x; M21 = t.y; M22 = t.z; } return this; }
public Matrix4d SetRotation(Tuple3dc axis, double angle) { double s = Math.Sin(angle); double c = Math.Cos(angle); double t = 1 - c; Tuple3dc myp = ~axis; double x = myp.x; double y = myp.y; double z = myp.z; M00 = t * x * x + c; M01 = t * x * y - s * z; M02 = t * x * z + s * y; M10 = t * x * y + s * z; M11 = t * y * y + c; M12 = t * y * z - s * x; M20 = t * x * z - s * y; M21 = t * y * z + s * x; M22 = t * z * z + c; M03 = M13 = M23 = 0; M30 = M31 = M32 = 0; M33 = 1; return this; }
public Matrix4d SetTranslation(Tuple3dc tuple) { M00 = 1; M01 = 0; M02 = 0; M03 = tuple.x; M10 = 0; M11 = 1; M12 = 0; M13 = tuple.y; M20 = 0; M21 = 0; M22 = 1; M23 = tuple.z; M30 = 0; M31 = 0; M32 = 0; M33 = 1; return this; }
public Matrix4d SetRows(Tuple3dc row0, Tuple3dc row1, Tuple3dc row2, Tuple3dc row3) { M00 = row0.x; M01 = row0.y; M02 = row0.z; M03 = 0; M10 = row1.x; M11 = row1.y; M12 = row1.z; M13 = 0; M20 = row2.x; M21 = row2.y; M22 = row2.z; M23 = 0; M30 = row3.x; M31 = row3.y; M32 = row3.z; M33 = 1; return this; }
public Matrix4d SetColumns(Tuple3dc column0, Tuple3dc column1, Tuple3dc column2, Tuple3dc column3) { M00 = column0.x; M01 = column1.x; M02 = column2.x; M03 = column3.x; M10 = column0.y; M11 = column1.y; M12 = column2.y; M13 = column3.y; M20 = column0.z; M21 = column1.z; M22 = column2.z; M23 = column3.z; M30 = 0; M31 = 0; M32 = 0; M33 = 1; return this; }
public void GetRows(out Tuple3dc r0, out Tuple3dc r1, out Tuple3dc r2) { r0 = new Tuple3dc(M00, M01, M02); r1 = new Tuple3dc(M10, M11, M12); r2 = new Tuple3dc(M20, M21, M22); }
public static void TestConstructor() { // Prepare test Tuple3dc tuple = new Tuple3dc(1, 2, 3); // Execute test Assert.AreEqual(1, tuple.x); Assert.AreEqual(2, tuple.y); Assert.AreEqual(3, tuple.z); }
public static Matrix4d RotationMatrix(Tuple3dc axis, double angle) { return new Matrix4d().SetRotation(axis, angle); }
public static void TestEpsilonEquals2D() { // Prepare test Tuple3dc a = new Tuple3dc(1, 2, 3); Tuple3dc b = new Tuple3dc(1.05, 2.05, 3.05); Tuple3dc c = new Tuple3dc(1, 2, 3.20); Tuple3dc d = new Tuple3dc(1, 2.20, 3.20); bool equalsAB = a.EpsilonEquals2D(b, 0.1); bool equalsAC = a.EpsilonEquals2D(c, 0.1); bool equalsAD = a.EpsilonEquals2D(d, 0.1); // Execute test Assert.AreEqual(true, equalsAB); Assert.AreEqual(true, equalsAC); Assert.AreEqual(false, equalsAD); }
public Matrix3d SetColumn(Tuple3dc t, int c) { if (c == 0) { M00 = t.x; M10 = t.y; M20 = t.z; } if (c == 1) { M01 = t.x; M11 = t.y; M21 = t.z; } if (c == 2) { M02 = t.x; M12 = t.y; M22 = t.z; } return this; }
public static void TestUnaryOperatorMagnitude() { // Prepare test Tuple3dc tuple = new Tuple3dc(1, 2, 3); double magnitude = !tuple; // Execute test Assert.AreEqual(3.74165738677394, magnitude, delta); }
public static Matrix4d ScaleMatrix(Tuple3dc tuple) { return new Matrix4d().SetScale(tuple); }
public static void TestUnaryOperatorPlus() { // Prepare test Tuple3dc tuple = new Tuple3dc(1, 2, 3); tuple = +tuple; // Execute test Assert.AreEqual(1, tuple.x); Assert.AreEqual(2, tuple.y); Assert.AreEqual(3, tuple.z); }
public static void TestBinaryOperatorDotProductWithITuple() { // Prepare test Tuple3dc a = new Tuple3dc(1, 2, 3); ITuple b = new Tuple3dc(4, 5, 6); double c = a * b; // Execute test Assert.AreEqual(32, c, delta); }
public static Matrix4d TranslationMatrix(Tuple3dc tuple) { return new Matrix4d().SetTranslation(tuple); }
public Matrix3d SetRows(Tuple3dc r0, Tuple3dc r1, Tuple3dc r2) { M00 = r0.x; M01 = r0.y; M02 = r0.z; M10 = r1.x; M11 = r1.y; M12 = r1.z; M20 = r2.x; M21 = r2.y; M22 = r2.z; return this; }