public void Vector4_CalculatesLengthCorrectly() { var vector = new Vector4(123.4f, 567.8f, 901.2f, 345.6f); TheResultingValue(vector.Length()).WithinDelta(0.1f) .ShouldBe((float)Math.Sqrt((123.4f * 123.4f) + (567.8f * 567.8f) + (901.2f * 901.2f) + (345.6f * 345.6f))); }
public void Vector4LengthTest() { Vector3 a = new Vector3(1.0f, 2.0f, 3.0f); float w = 4.0f; Vector4 target = new Vector4(a, w); float expected = (float)System.Math.Sqrt(30.0f); float actual; actual = target.Length(); Assert.IsTrue(MathHelper.Equal(expected, actual), "Vector4.Length did not return the expected value."); }
public void Vector4LengthTest1() { Vector4 target = new Vector4(); float expected = 0.0f; float actual = target.Length(); Assert.IsTrue(MathHelper.Equal(expected, actual), "Vector4.Length did not return the expected value."); }
public void TestStaticFn_Length_i () { Vector4 a = new Vector4(3, -4, 12, 84); Double expected = 85; Double result = a.Length(); Assert.That(result, Is.EqualTo(expected)); }
public static Vector4 MinLength(Vector4 value, float minLength) => value.Length() < minLength?Vector4.Normalize(value) * minLength : value;
public static Vector4 MaxLength(Vector4 value, float maxLength) => value.Length() > maxLength?Vector4.Normalize(value) * maxLength : value;