public void EvaluateTest() { // Arrange MAT3 a = new MAT3( new VEC3[3] { new VEC3(3, 2, 1), new VEC3(4, 5, 6), new VEC3(7, 5, 9) }); VEC3 v = new VEC3(1, 2, 7); double expected_x = a[0][0] * v[0] + a[0][1] * v[1] + a[0][2] * v[2]; double expected_y = a[1][0] * v[0] + a[1][1] * v[1] + a[1][2] * v[2]; double expected_z = a[2][0] * v[0] + a[2][1] * v[1] + a[2][2] * v[2]; // Act VEC3 r = MAT3.Evaluate(in a, in v); double actual_x = r[0]; double actual_y = r[1]; double actual_z = r[2]; // Assert Assert.AreEqual(expected_x, actual_x, double.Epsilon); Assert.AreEqual(expected_y, actual_y, double.Epsilon); Assert.AreEqual(expected_z, actual_z, double.Epsilon); }
public void LengthTest() { // Arrange double x = 3.0, y = 4.0, z = 5.0; VEC3 v = new VEC3(x, y, z); double expected = Math.Sqrt((x * x) + (y * y) + (z * z)); // Act double actual = v.Length; // Assert Assert.AreEqual(expected, actual, double.Epsilon); }
public void DotTest() { // Arrange double ax = 2.0, ay = 3.0, az = 4.0; VEC3 a = new VEC3(ax, ay, az); double bx = 5.0, by = 6.0, bz = 7.0; VEC3 b = new VEC3(bx, by, bz); double expected = (ax * bx) + (ay * by) + (az * bz); // Act double actual = VEC3.Dot(a, b); // Assert Assert.AreEqual(expected, actual); }
public void DistanceTest() { // Arrange double ax = 2.0, ay = 3.0, az = 4.0; VEC3 a = new VEC3(ax, ay, az); double bx = 5.0, by = 6.0, bz = 7.0; VEC3 b = new VEC3(bx, by, bz); VEC3 d = a - b; double expected = Math.Sqrt((d[0] * d[0]) + (d[1] * d[1]) + (d[2] * d[2])); // Act double actual = VEC3.Distance(a, b); // Assert Assert.AreEqual(expected, actual, double.Epsilon); }
public void InitTest() { // Arrange double expected_x = 1.0; double expected_y = 2.0; double expected_z = 3.0; // Act VEC3 v = new VEC3(expected_x, expected_y, expected_z); double actual_x = v[0]; double actual_y = v[1]; double actual_z = v[2]; // Assert Assert.AreEqual(expected_x, actual_x); Assert.AreEqual(expected_y, actual_y); Assert.AreEqual(expected_z, actual_z); }
public void SolveTest() { // Arrange MAT3 a = new MAT3( new VEC3[3] { new VEC3(3, 2, 1), new VEC3(4, 5, 6), new VEC3(7, 5, 9) }); VEC3 b = new VEC3(1, 2, 7); // Act bool solved = MAT3.Solve(in a, in b, out VEC3 _); // Assert Assert.IsTrue(solved); }
public void MinusTest() { // Arrange double ax = 10.0, ay = 9.0, az = 8.0; VEC3 a = new VEC3(ax, ay, az); double bx = 9.0, by = 7.0, bz = 5.0; VEC3 b = new VEC3(bx, by, bz); double expected_x = ax - bx, expected_y = ay - by, expected_z = az - bz; // Act VEC3 actual = a - b; double actual_x = actual[0]; double actual_y = actual[1]; double actual_z = actual[2]; // Assert Assert.AreEqual(expected_x, actual_x); Assert.AreEqual(expected_y, actual_y); Assert.AreEqual(expected_z, actual_z); }
public void CrossTest() { // Arrange double ax = 2.0, ay = 3.0, az = 4.0; VEC3 a = new VEC3(ax, ay, az); double bx = 5.0, by = 6.0, bz = 7.0; VEC3 b = new VEC3(bx, by, bz); double expected_x = (ay * bz) - (az * by), expected_y = (az * bx) - (ax * bz), expected_z = (ax * by) - (ay * bx); // Act VEC3 actual = VEC3.Cross(a, b); double actual_x = actual[0]; double actual_y = actual[1]; double actual_z = actual[2]; // Assert Assert.AreEqual(expected_x, actual_x); Assert.AreEqual(expected_y, actual_y); Assert.AreEqual(expected_z, actual_z); }
public static Vector3 Vec3ToUnityVector3(VEC3 v) { return(new Vector3(v.X, v.Y, v.Z)); }
private static extern void VEC3minus_Internal( ref VEC3 r, in VEC3 a,
internal static void VEC3init(ref VEC3 v, double x, double y, double z) { VEC3init_Internal(ref v, x, y, z); }
private static extern void VEC3init_Internal( ref VEC3 v, [MarshalAs(UnmanagedType.R8)] double x, [MarshalAs(UnmanagedType.R8)] double y, [MarshalAs(UnmanagedType.R8)] double z);