public void Dot() { Vector4F a = new Vector4F(1.0f, 2.0f, 3.0f, 4.0f); Vector4F b = new Vector4F(4.0f, 5.0f, 6.0f, 7.0f); double dot = a.Dot(b); Assert.AreEqual(1.0f * 4.0f + 2.0f * 5.0f + 3.0f * 6.0f + 4.0f * 7.0f, dot, 1e-14); }
public void Construct2() { Vector4F v = new Vector4F(new Vector2F(1.0f, 2.0f), 3.0f, 4.0f); Assert.AreEqual(1.0f, v.X); Assert.AreEqual(2.0f, v.Y); Assert.AreEqual(3.0f, v.Z); Assert.AreEqual(4.0f, v.W); }
public void TestGetHashCode() { Vector4F a = new Vector4F(1.0f, 2.0f, 3.0f, 4.0f); Vector4F b = new Vector4F(4.0f, 5.0f, 6.0f, 7.0f); Vector4F c = new Vector4F(1.0f, 2.0f, 3.0f, 4.0f); Assert.AreEqual(a.GetHashCode(), c.GetHashCode()); Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode()); }
public void XYZ() { Vector4F a = new Vector4F(1.23f, 2.34f, 3.45f, 4.56f); Vector3F xyz = a.XYZ; Assert.AreEqual(1.23f, xyz.X, 1e-14); Assert.AreEqual(2.34f, xyz.Y, 1e-14); Assert.AreEqual(3.45f, xyz.Z, 1e-14); }
public void ToVector4D() { Vector4F a = new Vector4F(1.0f, 2.0f, 3.0f, 4.0f); Vector4D dA = a.ToVector4D(); Assert.AreEqual(1.0, dA.X, 1e-7); Assert.AreEqual(2.0, dA.Y, 1e-7); Assert.AreEqual(3.0, dA.Z, 1e-7); Assert.AreEqual(4.0, dA.W, 1e-7); }
public void ToVector4F() { Vector4H a = new Vector4H(1.0, 2.0, 3.0, 4.0); Vector4F sA = a.ToVector4F(); Assert.AreEqual(1.0f, sA.X, 1e-7); Assert.AreEqual(2.0f, sA.Y, 1e-7); Assert.AreEqual(3.0f, sA.Z, 1e-7); Assert.AreEqual(4.0f, sA.W, 1e-7); }
public void ToVector4F() { Vector4I a = new Vector4I(1, 2, 3, 4); Vector4F sA = a.ToVector4F(); Assert.AreEqual(1.0f, sA.X, 1e-7); Assert.AreEqual(2.0f, sA.Y, 1e-7); Assert.AreEqual(3.0f, sA.Z, 1e-7); Assert.AreEqual(4.0f, sA.W, 1e-7); }
public void ToVector4B() { Vector4F a = new Vector4F(1.0f, 0.0f, 0.0f, 1.0f); Vector4B dA = a.ToVector4B(); Assert.IsTrue(dA.X); Assert.IsFalse(dA.Y); Assert.IsFalse(dA.Z); Assert.IsTrue(dA.W); }
public void ToVector4H() { Vector4F a = new Vector4F(1.0f, 2.0f, 3.0f, 4.0f); Vector4H sA = a.ToVector4H(); Assert.AreEqual((Half)1.0f, sA.X, 1e-7); Assert.AreEqual((Half)2.0f, sA.Y, 1e-7); Assert.AreEqual((Half)3.0f, sA.Z, 1e-7); Assert.AreEqual((Half)4.0f, sA.W, 1e-7); }
public void ToVector4I() { Vector4F a = new Vector4F(1.0f, 2.0f, 3.0f, 4.0f); Vector4I dA = a.ToVector4I(); Assert.AreEqual(1, dA.X); Assert.AreEqual(2, dA.Y); Assert.AreEqual(3, dA.Z); Assert.AreEqual(4, dA.W); }
public void ToVector4F() { Vector4B a = new Vector4B(false, false, true, true); Vector4F sA = a.ToVector4F(); Assert.AreEqual(0.0f, sA.X, 1e-7); Assert.AreEqual(0.0f, sA.Y, 1e-7); Assert.AreEqual(1.0f, sA.Z, 1e-7); Assert.AreEqual(1.0f, sA.W, 1e-7); }
public void TestToString() { CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture; try { Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR"); Vector4F a = new Vector4F(1.23f, 2.34f, 3.45f, 4.56f); Assert.AreEqual("(1,23, 2,34, 3,45, 4,56)", a.ToString()); } finally { Thread.CurrentThread.CurrentCulture = originalCulture; } }
public void Divide() { Vector4F v1 = new Vector4F(10.0f, 20.0f, 30.0f, 40.0f); Vector4F v2 = v1 / 5.0f; Assert.AreEqual(2.0f, v2.X, 1e-14); Assert.AreEqual(4.0f, v2.Y, 1e-14); Assert.AreEqual(6.0f, v2.Z, 1e-14); Assert.AreEqual(8.0f, v2.W, 1e-14); Vector4F v3 = v1.Divide(5.0f); Assert.AreEqual(2.0f, v3.X, 1e-14); Assert.AreEqual(4.0f, v3.Y, 1e-14); Assert.AreEqual(6.0f, v3.Z, 1e-14); Assert.AreEqual(8.0f, v3.W, 1e-14); }
public void MostOrthogonalAxis() { Vector4F v1 = new Vector4F(1, 2, 3, 4); Assert.AreEqual(Vector4F.UnitX, v1.MostOrthogonalAxis); Vector4F v2 = new Vector4F(-3, -1, -2, -4); Assert.AreEqual(Vector4F.UnitY, v2.MostOrthogonalAxis); Vector4F v3 = new Vector4F(3, 2, 1, 4); Assert.AreEqual(Vector4F.UnitZ, v3.MostOrthogonalAxis); Vector4F v4 = new Vector4F(3, 2, 4, 1); Assert.AreEqual(Vector4F.UnitW, v4.MostOrthogonalAxis); }
public void Magnitude() { Vector4F v = new Vector4F(3.0f, 4.0f, 0.0f, 0.0f); Assert.AreEqual(25.0f, v.MagnitudeSquared, 1e-14); Assert.AreEqual(5.0f, v.Magnitude, 1e-14); v = new Vector4F(3.0f, 0.0f, 4.0f, 0.0f); Assert.AreEqual(25.0f, v.MagnitudeSquared, 1e-14); Assert.AreEqual(5.0f, v.Magnitude, 1e-14); v = new Vector4F(0.0f, 3.0f, 4.0f, 0.0f); Assert.AreEqual(25.0f, v.MagnitudeSquared, 1e-14); Assert.AreEqual(5.0f, v.Magnitude, 1e-14); v = new Vector4F(0.0f, 0.0f, 3.0f, 4.0f); Assert.AreEqual(25.0f, v.MagnitudeSquared, 1e-14); Assert.AreEqual(5.0f, v.Magnitude, 1e-14); }
public void Add() { Vector4F v1 = new Vector4F(1.0f, 2.0f, 3.0f, 4.0f); Vector4F v2 = new Vector4F(4.0f, 5.0f, 6.0f, 7.0f); Vector4F v3 = v1 + v2; Assert.AreEqual(5.0f, v3.X, 1e-14); Assert.AreEqual(7.0f, v3.Y, 1e-14); Assert.AreEqual(9.0f, v3.Z, 1e-14); Assert.AreEqual(11.0f, v3.W, 1e-14); Vector4F v4 = v1.Add(v2); Assert.AreEqual(5.0f, v4.X, 1e-14); Assert.AreEqual(7.0f, v4.Y, 1e-14); Assert.AreEqual(9.0f, v4.Z, 1e-14); Assert.AreEqual(11.0f, v4.W, 1e-14); }
public void Subtract() { Vector4F v1 = new Vector4F(1.0f, 2.0f, 3.0f, 4.0f); Vector4F v2 = new Vector4F(4.0f, 5.0f, 6.0f, 7.0f); Vector4F v3 = v1 - v2; Assert.AreEqual(-3.0f, v3.X, 1e-14); Assert.AreEqual(-3.0f, v3.Y, 1e-14); Assert.AreEqual(-3.0f, v3.Z, 1e-14); Assert.AreEqual(-3.0f, v3.W, 1e-14); Vector4F v4 = v1.Subtract(v2); Assert.AreEqual(-3.0f, v4.X, 1e-14); Assert.AreEqual(-3.0f, v4.Y, 1e-14); Assert.AreEqual(-3.0f, v4.Z, 1e-14); Assert.AreEqual(-3.0f, v4.W, 1e-14); }
public void NormalizeZeroVector() { Vector4F v = new Vector4F(0.0f, 0.0f, 0.0f, 0.0f); Vector4F n1 = v.Normalize(); Assert.IsNaN(n1.X); Assert.IsNaN(n1.Y); Assert.IsNaN(n1.Z); Assert.IsTrue(n1.IsUndefined); float magnitude; Vector4F n2 = v.Normalize(out magnitude); Assert.IsNaN(n2.X); Assert.IsNaN(n2.Y); Assert.IsNaN(n2.Z); Assert.IsTrue(n2.IsUndefined); Assert.AreEqual(0.0f, magnitude); }