#if !UNITY_5_6_OR_NEWER using NUnit.Framework; namespace LinearAlgebra.Test { using Vector3 = Vector3Float; public class Vector3FloatTest { [Test] public void FromSpherical() { Vector3 v = new(0, 0, 1); Spherical s = Spherical.FromVector3(v); Vector3 r = Vector3.FromSpherical(s); Assert.AreEqual(0, r.horizontal, "0 0 1"); Assert.AreEqual(0, r.vertical, 1.0e-06, "0 0 1"); Assert.AreEqual(1, r.depth, "0 0 1"); v = new(0, 1, 0); s = Spherical.FromVector3(v); r = Vector3.FromSpherical(s); Assert.AreEqual(0, r.horizontal, "0 0 1"); Assert.AreEqual(1, r.vertical, "0 0 1"); Assert.AreEqual(0, r.depth, 1.0e-06, "0 0 1"); v = new(1, 0, 0); s = Spherical.FromVector3(v); r = Vector3.FromSpherical(s); Assert.AreEqual(1, r.horizontal, "0 0 1"); Assert.AreEqual(0, r.vertical, 1.0e-06, "0 0 1"); Assert.AreEqual(0, r.depth, 1.0e-06, "0 0 1"); } [Test] public void Magnitude() { Vector3 v = new(1, 2, 3); float m = 0; m = v.magnitude; Assert.AreEqual(3.7416575f, m, "magnitude 1 2 3"); m = Vector3.MagnitudeOf(v); Assert.AreEqual(3.7416575f, m, "MagnitudeOf 1 2 3"); v = new(-1, -2, -3); m = v.magnitude; Assert.AreEqual(3.7416575f, m, "magnitude -1 -2 -3"); v = new(0, 0, 0); m = v.magnitude; Assert.AreEqual(0, m, "magnitude 0 0 0"); // Infinity tests are still missing } [Test] public void SqrMagnitude() { Vector3 v = new(1, 2, 3); float m = 0; m = v.sqrMagnitude; Assert.AreEqual(14, m, "sqrMagnitude 1 2 3"); m = Vector3.SqrMagnitudeOf(v); Assert.AreEqual(14, m, "SqrMagnitudeOf 1 2 3"); v = new(-1, -2, -3); m = v.sqrMagnitude; Assert.AreEqual(14, m, "sqrMagnitude -1 -2 -3"); v = new(0, 0, 0); m = v.sqrMagnitude; Assert.AreEqual(0, m, "sqrMagnitude 0 0 0"); // Infinity tests are still missing } [Test] public void Normalize() { Vector3 v = new(0, 2, 0); Vector3 r; r = v.normalized; Assert.AreEqual(new Vector3(0, 1, 0), r, "normalized 0 2 0"); r = Vector3.Normalize(v); Assert.AreEqual(new Vector3(0, 1, 0), r, "Normalize 0 2 0"); v = new(0, -2, 0); r = v.normalized; Assert.AreEqual(new Vector3(0, -1, 0), r, "normalized 0 -2 0"); v = new(0, 0, 0); r = v.normalized; Assert.AreEqual(new Vector3(0, 0, 0), r, "normalized 0 0 0"); v = new(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); r = v.normalized; Assert.IsTrue(float.IsNaN(r.horizontal), "normalized infinity infinity infinity"); Assert.IsTrue(float.IsNaN(r.vertical), "normalized infinity infinity infinity"); Assert.IsTrue(float.IsNaN(r.depth), "normalized infinity infinity infinity"); v = new(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity); r = v.normalized; Assert.IsTrue(float.IsNaN(r.horizontal), "normalized -infinity -infinity -infinity"); Assert.IsTrue(float.IsNaN(r.vertical), "normalized -infinity -infinity -infinity"); Assert.IsTrue(float.IsNaN(r.depth), "normalized -infinity -infinity -infinity"); } [Test] public void Negate() { Vector3 v = new(4, 5, 6); Vector3 r; r = -v; Assert.AreEqual(-4, r.horizontal, "- 4 5 6 H"); Assert.AreEqual(-5, r.vertical, "- 4 5 6 V"); Assert.AreEqual(-6, r.depth, "- 4 5 6 D"); v = new(-4, -5, -6); r = -v; Assert.AreEqual(4, r.horizontal, "- -4 -5 -6 H"); Assert.AreEqual(5, r.vertical, "- -4 -5 -6 V"); Assert.AreEqual(6, r.depth, "- -4 -5 -6 D"); v = new(0, 0, 0); r = -v; Assert.AreEqual(new Vector3(0, 0, 0), r, "- 0 0 0"); Assert.AreEqual(0, r.horizontal, "- 0 0 0 H"); Assert.AreEqual(0, r.vertical, "- 0 0 0 V"); Assert.AreEqual(0, r.depth, "- 0 0 0 D"); v = new(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); r = -v; Assert.AreEqual(new Vector3(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity), r, "- inifinty infinity infinity"); v = new(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity); r = -v; Assert.AreEqual(new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity), r, "- -inifinty -infinity -infinity"); } [Test] public void Subtract() { Vector3 v1 = new(4, 5, 6); Vector3 v2 = new(1, 2, 3); Vector3 r = Vector3.zero; r = v1 - v2; Assert.IsTrue(r == new Vector3(3, 3, 3), "4 5 6 - 1 2 3"); v2 = new(-1, -2, -3); r = v1 - v2; Assert.IsTrue(r == new Vector3(5, 7, 9), "4 5 6 - -1 -2 -3"); v2 = new(4, 5, 6); r = v1 - v2; Assert.IsTrue(r == new Vector3(0, 0, 0), "4 5 6 - 4 5 6"); r = v1; r -= v2; Assert.AreEqual(r, new Vector3(0, 0, 0), "4 5 6 - 4 5 6"); v2 = new(0, 0, 0); r = v1 - v2; Assert.AreEqual(r, new Vector3(4, 5, 6), "4 5 6 - 0 0 0"); r -= v2; Assert.AreEqual(r, new Vector3(4, 5, 6), "4 5 6 - 0 0 0"); // Infinity tests are still missing } [Test] public void Addition() { Vector3 v1 = new(4, 5, 6); Vector3 v2 = new(1, 2, 3); Vector3 r = Vector3.zero; r = v1 + v2; Assert.IsTrue(r == new Vector3(5, 7, 9), "4 5 6 + 1 2 3"); v2 = new(-1, -2, -3); r = v1 + v2; Assert.IsTrue(r == new Vector3(3, 3, 3), "4 5 6 + -1 -2 -3"); r = v1; r += v2; Assert.AreEqual(r, new Vector3(3, 3, 3), "4 5 6 + -1 -2 -3"); v2 = new(0, 0, 0); r = v1 + v2; Assert.AreEqual(r, new Vector3(4, 5, 6), "4 5 6 + 0 0 0"); r += v2; Assert.AreEqual(r, new Vector3(4, 5, 6), "4 5 6 + 0 0 0"); // Infinity tests are still missing } [Test] public void Scale() { Vector3 v1 = new(4, 5, 6); Vector3 v2 = new(1, 2, 3); Vector3 r; r = Vector3.Scale(v1, v2); Assert.AreEqual(4, r.horizontal, "Scale 4 5 6 , 1 2 3 H"); Assert.AreEqual(10, r.vertical, "Scale 4 5 6 , 1 2 3 V"); Assert.AreEqual(18, r.depth, "Scale 4 5 6 , 1 2 3 D"); v2 = new(-1, -2, -3); r = Vector3.Scale(v1, v2); Assert.AreEqual(-4, r.horizontal, "Scale 4 5 6 , -1 -2 -3 H"); Assert.AreEqual(-10, r.vertical, "Scale 4 5 6 , -1 -2 -3 V"); Assert.AreEqual(-18, r.depth, "Scale 4 5 6 , -1 -2 -3 D"); v2 = new(0, 0, 0); r = Vector3.Scale(v1, v2); Assert.AreEqual(0, r.horizontal, "Scale 4 5 6 , 0 0 0 H"); Assert.AreEqual(0, r.vertical, "Scale 4 5 6 , 0 0 0 V"); Assert.AreEqual(0, r.depth, "Scale 4 5 6 , 0 0 0 D"); v2 = new(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); r = Vector3.Scale(v1, v2); Assert.AreEqual(float.PositiveInfinity, r.horizontal, "Scale 4 5 6 , inf inf inf H"); Assert.AreEqual(float.PositiveInfinity, r.vertical, "Scale 4 5 6 , inf inf inf V"); Assert.AreEqual(float.PositiveInfinity, r.depth, "Scale 4 5 6 , inf inf inf D"); v2 = new(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity); r = Vector3.Scale(v1, v2); Assert.AreEqual(float.NegativeInfinity, r.horizontal, "Scale 4 5 6 , -inf -inf -inf H"); Assert.AreEqual(float.NegativeInfinity, r.vertical, "Scale 4 5 6 , -inf -inf -inf V"); Assert.AreEqual(float.NegativeInfinity, r.depth, "Scale 4 5 6 , -inf -inf -inf D"); } [Test] public void Multiply() { Vector3 v1 = new(4, 5, 6); float f = 3; Vector3 r; r = v1 * f; Assert.AreEqual(12, r.horizontal, "4 5 6 * 3 H"); Assert.AreEqual(15, r.vertical, "4 5 6 * 3 V"); Assert.AreEqual(18, r.depth, "4 5 6 * 3 D"); f = -3; r = v1 * f; Assert.AreEqual(-12, r.horizontal, "4 5 6 * -3 H"); Assert.AreEqual(-15, r.vertical, "4 5 6 * -3 V"); Assert.AreEqual(-18, r.depth, "4 5 6 * -3 D"); f = 0; r = v1 * f; Assert.AreEqual(0, r.horizontal, "4 5 6 * 0 H"); Assert.AreEqual(0, r.vertical, "4 5 6 * 0 V"); Assert.AreEqual(0, r.depth, "4 5 6 * 0 D"); f = float.PositiveInfinity; r = v1 * f; Assert.AreEqual(float.PositiveInfinity, r.horizontal, "4 5 6 * inf H"); Assert.AreEqual(float.PositiveInfinity, r.vertical, "4 5 6 * inf V"); Assert.AreEqual(float.PositiveInfinity, r.depth, "4 5 6 * inf D"); f = float.NegativeInfinity; r = v1 * f; Assert.AreEqual(float.NegativeInfinity, r.horizontal, "4 5 6 * -inf H"); Assert.AreEqual(float.NegativeInfinity, r.vertical, "4 5 6 * -inf V"); Assert.AreEqual(float.NegativeInfinity, r.depth, "4 5 6 * -inf D"); } [Test] public void Divide() { Vector3 v1 = new(4, 5, 6); float f = 2; Vector3 r; r = v1 / f; Assert.AreEqual(2, r.horizontal, "4 5 6 / 2 H"); Assert.AreEqual(2.5, r.vertical, "4 5 6 / 2 V"); Assert.AreEqual(3, r.depth, "4 5 6 / 2 D"); f = -2; r = v1 / f; Assert.AreEqual(-2, r.horizontal, "4 5 6 / -2 H"); Assert.AreEqual(-2.5, r.vertical, "4 5 6 / -2 V"); Assert.AreEqual(-3, r.depth, "4 5 6 / -2 D"); f = 0; r = v1 / f; Assert.AreEqual(float.PositiveInfinity, r.horizontal, "4 5 6 / 0 H"); Assert.AreEqual(float.PositiveInfinity, r.vertical, "4 5 6 / 0 V"); Assert.AreEqual(float.PositiveInfinity, r.depth, "4 5 6 / 0 D"); f = float.PositiveInfinity; r = v1 / f; Assert.AreEqual(0, r.horizontal, "4 5 6 / inf H"); Assert.AreEqual(0, r.vertical, "4 5 6 / inf V"); Assert.AreEqual(0, r.depth, "4 5 6 / inf D"); f = float.NegativeInfinity; r = v1 / f; Assert.AreEqual(0, r.horizontal, "4 5 6 / -inf H"); Assert.AreEqual(0, r.vertical, "4 5 6 / -inf V"); Assert.AreEqual(0, r.depth, "4 5 6 / -inf D"); } [Test] public void Dot() { Vector3 v1 = new(4, 5, 6); Vector3 v2 = new(1, 2, 3); float f; f = Vector3.Dot(v1, v2); Assert.AreEqual(32, f, "Dot(4 5 6, 1 2 3)"); v2 = new(-1, -2, -3); f = Vector3.Dot(v1, v2); Assert.AreEqual(-32, f, "Dot(4 5 6, -1 -2 -3)"); v2 = new(0, 0, 0); f = Vector3.Dot(v1, v2); Assert.AreEqual(0, f, "Dot(4 5 6, 0 0 0)"); v2 = new(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); f = Vector3.Dot(v1, v2); Assert.AreEqual(float.PositiveInfinity, f, "Dot(4 5 6, inf inf inf)"); v2 = new(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity); f = Vector3.Dot(v1, v2); Assert.AreEqual(float.NegativeInfinity, f, "Dot(4 5 6, -inf -inf -inf)"); } [Test] public void Equality() { Vector3 v1 = new(4, 5, 6); Vector3 v2 = new(1, 2, 3); bool r; r = v1 == v2; Assert.IsFalse(r, "4 5 6 == 1 2 3"); v2 = new(4, 5, 6); r = v1 == v2; Assert.IsTrue(r, "4 5 6 == 4 5 6"); v2 = new(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); r = v1 == v2; Assert.IsFalse(r, "4 5 6 == inf inf inf"); v1 = new(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity); r = v1 == v2; Assert.IsFalse(r, "-inf -inf -inf == inf inf inf"); } [Test] public void Distance() { Vector3 v1 = new(4, 5, 6); Vector3 v2 = new(1, 2, 3); float f; f = Vector3.Distance(v1, v2); Assert.AreEqual(5.19615221F, f, "Distance(4 5 6, 1 2 3)"); v2 = new(-1, -2, -3); f = Vector3.Distance(v1, v2); Assert.AreEqual(12.4498997F, f, "Distance(4 5 6, -1 -2 -3)"); v2 = new(0, 0, 0); f = Vector3.Distance(v1, v2); Assert.AreEqual(v1.magnitude, f, "Distance(4 5 6, 0 0 0)"); v2 = new(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); f = Vector3.Distance(v1, v2); Assert.AreEqual(float.PositiveInfinity, f, "Distance(4 5 6, inf inf inf)"); v2 = new(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity); f = Vector3.Distance(v1, v2); Assert.AreEqual(float.PositiveInfinity, f, "Distance(4 5 6, -inf -inf -inf)"); } [Test] public void Cross() { Vector3 v1 = new(4, 5, 6); Vector3 v2 = new(1, 2, 3); Vector3 r; r = Vector3.Cross(v1, v2); Assert.AreEqual(3, r.horizontal, "Cross(4 5 6, 1 2 3) H"); Assert.AreEqual(-6, r.vertical, "Cross(4 5 6, 1 2 3) V"); Assert.AreEqual(3, r.depth, "Cross(4 5 6, 1 2 3) D"); v2 = new(-1, -2, -3); r = Vector3.Cross(v1, v2); Assert.AreEqual(-3, r.horizontal, "Cross(4 5 6, -1 -2 -3) H"); Assert.AreEqual(6, r.vertical, "Cross(4 5 6, -1 -2 -3) V"); Assert.AreEqual(-3, r.depth, "Cross(4 5 6, -1 -2 -3) D"); v2 = new(0, 0, 0); r = Vector3.Cross(v1, v2); Assert.AreEqual(0, r.horizontal, "Cross(4 5 6, 0 0 0) H"); Assert.AreEqual(0, r.vertical, "Cross(4 5 6, 0 0 0) V"); Assert.AreEqual(0, r.depth, "Cross(4 5 6, 0 0 0) D"); v2 = new(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); r = Vector3.Cross(v1, v2); Assert.IsTrue(float.IsNaN(r.horizontal), "Cross(4 5 6, inf inf inf) H"); Assert.IsTrue(float.IsNaN(r.vertical), "Cross(4 5 6, inf inf inf) V"); Assert.IsTrue(float.IsNaN(r.depth), "Cross(4 5 6, inf inf inf) D"); v2 = new(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity); r = Vector3.Cross(v1, v2); Assert.IsTrue(float.IsNaN(r.horizontal), "Cross(4 5 6, -inf -inf -inf) H"); Assert.IsTrue(float.IsNaN(r.vertical), "Cross(4 5 6, -inf -inf -inf) V"); Assert.IsTrue(float.IsNaN(r.depth), "Cross(4 5 6, -inf -inf -inf) D"); } [Test] public void Project() { Vector3 v1 = new(4, 5, 6); Vector3 v2 = new(1, 2, 3); Vector3 r; r = Vector3.Project(v1, v2); Assert.AreEqual(2.28571439F, r.horizontal, "Project(4 5 6, 1 2 3) H"); Assert.AreEqual(4.57142878F, r.vertical, "Project(4 5 6, 1 2 3) V"); Assert.AreEqual(6.85714293F, r.depth, "Project(4 5 6, 1 2 3) D"); v2 = new(-1, -2, -3); r = Vector3.Project(v1, v2); Assert.AreEqual(2.28571439F, r.horizontal, "Project(4 5 6, -1 -2 -3) H"); Assert.AreEqual(4.57142878F, r.vertical, "Project(4 5 6, -1 -2 -3) V"); Assert.AreEqual(6.85714293F, r.depth, "Project(4 5 6, -1 -2 -3) D"); v2 = new(0, 0, 0); r = Vector3.Project(v1, v2); Assert.AreEqual(0, r.horizontal, "Project(4 5 6, 0 0 0) H"); Assert.AreEqual(0, r.vertical, "Project(4 5 6, 0 0 0) V"); Assert.AreEqual(0, r.depth, "Project(4 5 6, 0 0 0) D"); r = Vector3.Project(v2, v1); Assert.AreEqual(0, r.horizontal, "Project(0 0 0, 4 5 6) H"); Assert.AreEqual(0, r.vertical, "Project(0 0 0, 4 5 6) V"); Assert.AreEqual(0, r.depth, "Project(0 0 0, 4 5 6) D"); v2 = new(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); r = Vector3.Project(v1, v2); Assert.IsTrue(float.IsNaN(r.horizontal), "Project(4 5 6, inf inf inf) H"); Assert.IsTrue(float.IsNaN(r.vertical), "Project(4 5 6, inf inf inf) V"); Assert.IsTrue(float.IsNaN(r.depth), "Project(4 5 6, inf inf inf) D"); v2 = new(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity); r = Vector3.Project(v1, v2); Assert.IsTrue(float.IsNaN(r.horizontal), "Project(4 5 6, -inf -inf -inf) H"); Assert.IsTrue(float.IsNaN(r.vertical), "Project(4 5 6, -inf -inf -inf) V"); Assert.IsTrue(float.IsNaN(r.depth), "Project(4 5 6, -inf -inf -inf) D"); } [Test] public void ProjectOnPlane() { Vector3 v1 = new(4, 5, 6); Vector3 v2 = new(1, 2, 3); Vector3 r; r = Vector3.ProjectOnPlane(v1, v2); Assert.AreEqual(1.71428561F, r.horizontal, "ProjectOnPlane(4 5 6, 1 2 3) H"); Assert.AreEqual(0.428571224F, r.vertical, "ProjectOnPlane(4 5 6, 1 2 3) V"); Assert.AreEqual(-0.857142925F, r.depth, "ProjectOnPlane(4 5 6, 1 2 3) D"); v2 = new(-1, -2, -3); r = Vector3.ProjectOnPlane(v1, v2); Assert.AreEqual(1.71428561F, r.horizontal, "ProjectOnPlane(4 5 6, -1 -2 -3) H"); Assert.AreEqual(0.428571224F, r.vertical, "ProjectOnPlane(4 5 6, -1 -2 -3) V"); Assert.AreEqual(-0.857142925F, r.depth, "ProjectOnPlane(4 5 6, -1 -2 -3) D"); v2 = new(0, 0, 0); r = Vector3.ProjectOnPlane(v1, v2); Assert.AreEqual(4, r.horizontal, "ProjectOnPlane(4 5 6, 0 0 0) H"); Assert.AreEqual(5, r.vertical, "ProjectOnPlane(4 5 6, 0 0 0) V"); Assert.AreEqual(6, r.depth, "ProjectOnPlane(4 5 6, 0 0 0) D"); r = Vector3.ProjectOnPlane(v2, v1); Assert.AreEqual(0, r.horizontal, "ProjectOnPlane(0 0 0, 4 5 6) H"); Assert.AreEqual(0, r.vertical, "ProjectOnPlane(0 0 0, 4 5 6) V"); Assert.AreEqual(0, r.depth, "ProjectOnPlane(0 0 0, 4 5 6) D"); v2 = new(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); r = Vector3.ProjectOnPlane(v1, v2); Assert.IsTrue(float.IsNaN(r.horizontal), "ProjectOnPlane(4 5 6, inf inf inf) H"); Assert.IsTrue(float.IsNaN(r.vertical), "ProjectOnPlane(4 5 6, inf inf inf) V"); Assert.IsTrue(float.IsNaN(r.depth), "ProjectOnPlane(4 5 6, inf inf inf) D"); v2 = new(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity); r = Vector3.ProjectOnPlane(v1, v2); Assert.IsTrue(float.IsNaN(r.horizontal), "ProjectOnPlane(4 5 6, -inf -inf -inf) H"); Assert.IsTrue(float.IsNaN(r.vertical), "ProjectOnPlane(4 5 6, -inf -inf -inf) V"); Assert.IsTrue(float.IsNaN(r.depth), "ProjectOnPlane(4 5 6, -inf -inf -inf) D"); } [Test] public void UnsignedAngle() { Vector3 v1 = new(4, 5, 6); Vector3 v2 = new(1, 2, 3); AngleFloat a; a = Vector3.UnsignedAngle(v1, v2); Assert.AreEqual(12.9331379F, a.inDegrees, "Angle(4 5 6, 1 2 3)"); v2 = new(-1, -2, -3); a = Vector3.UnsignedAngle(v1, v2); Assert.AreEqual(167.066849F, a.inDegrees, "Angle(4 5 6, -1 -2 -3)"); v2 = new(0, 0, 0); a = Vector3.UnsignedAngle(v1, v2); Assert.AreEqual(0, a.inDegrees, "Angle(4 5 6, 0 0 0)"); v2 = new(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); a = Vector3.UnsignedAngle(v1, v2); Assert.IsTrue(float.IsNaN(a.inDegrees), "Angle(4 5 6, inf inf inf)"); v2 = new(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity); a = Vector3.UnsignedAngle(v1, v2); Assert.IsTrue(float.IsNaN(a.inDegrees), "Angle(4 5 6, inf inf inf)"); } [Test] public void SignedAngle() { Vector3 v1 = new(4, 5, 6); Vector3 v2 = new(1, 2, 3); Vector3 v3 = new(7, 8, -9); AngleFloat a; a = Vector3.SignedAngle(v1, v2, v3); Assert.AreEqual(-12.9331379F, a.inDegrees, "SignedAngle(4 5 6, 1 2 3, 7 8 -9)"); v2 = new(-1, -2, -3); a = Vector3.SignedAngle(v1, v2, v3); Assert.AreEqual(167.066849F, a.inDegrees, "SignedAngle(4 5 6, -1 -2 -3, 7 8 -9)"); v2 = new(0, 0, 0); a = Vector3.SignedAngle(v1, v2, v3); Assert.AreEqual(0, a.inDegrees, "SignedAngle(4 5 6, 0 0 0, 7 8 -9)"); v2 = new(1, 2, 3); v3 = new(-7, -8, 9); a = Vector3.SignedAngle(v1, v2, v3); Assert.AreEqual(12.9331379F, a.inDegrees, "SignedAngle(4 5 6, 1 2 3, -7 -8 9)"); v3 = new(0, 0, 0); a = Vector3.SignedAngle(v1, v2, v3); Assert.AreEqual(0, a.inDegrees, "SignedAngle(4 5 6, 1 2 3, 0 0 0)"); v2 = new(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); a = Vector3.SignedAngle(v1, v2, v3); Assert.IsTrue(float.IsNaN(a.inDegrees), "SignedAngle(4 5 6, inf inf inf, 0 0 0)"); v2 = new(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity); a = Vector3.SignedAngle(v1, v2, v3); Assert.IsTrue(float.IsNaN(a.inDegrees), "SignedAngle(4 5 6, -inf -inf -inf, 0 0 0)"); } [Test] public void Lerp() { Vector3 v1 = new(4, 5, 6); Vector3 v2 = new(1, 2, 3); Vector3 r; r = Vector3.Lerp(v1, v2, 0); Assert.AreEqual(0, Vector3.Distance(r, v1), 0); r = Vector3.Lerp(v1, v2, 1); Assert.AreEqual(0, Vector3.Distance(r, v2), 0); r = Vector3.Lerp(v1, v2, 0.5f); Assert.AreEqual(0, Vector3.Distance(r, new Vector3(2.5f, 3.5f, 4.5f)), 0); r = Vector3.Lerp(v1, v2, -1); Assert.AreEqual(0, Vector3.Distance(r, new Vector3(7, 8, 9)), 0); r = Vector3.Lerp(v1, v2, 2); Assert.AreEqual(0, Vector3.Distance(r, new Vector3(-2, -1, 0)), 0); } } } #endif