public void Vector2NormalizeTest1() { Vector2 a = new Vector2(); // no parameter, default to 0.0f Vector2 actual = Vector2.Normalize(a); Assert.True(Single.IsNaN(actual.X) && Single.IsNaN(actual.Y), "Vector2f.Normalize did not return the expected value."); }
public void Vector2NormalizeTest2() { Vector2 a = new Vector2(Single.MaxValue, Single.MaxValue); Vector2 actual = Vector2.Normalize(a); Vector2 expected = new Vector2(0, 0); Assert.Equal(expected, actual); }
public void Vector2NormalizeTest() { Vector2 a = new Vector2(2.0f, 3.0f); Vector2 expected = new Vector2(0.554700196225229122018341733457f, 0.8320502943378436830275126001855f); Vector2 actual; actual = Vector2.Normalize(a); Assert.True(MathHelper.Equal(expected, actual), "Vector2f.Normalize did not return the expected value."); }
public static Vector2 NormalizeJitOptimizeCanaryTest() { var result = VectorTests.Vector2Value; for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) { result += Vector2.Normalize(result); } return(result); }
public void Vector2ReflectTest2() { Vector2 n = new Vector2(0.45f, 1.28f); n = Vector2.Normalize(n); Vector2 a = -n; Vector2 expected = n; Vector2 actual = Vector2.Reflect(a, n); Assert.True(MathHelper.Equal(expected, actual), "Vector2f.Reflect did not return the expected value."); }
public static Vector2 NormalizeTest() { var result = VectorTests.Vector2Value; for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) { // The inputs aren't being changed and the output is being reset with each iteration, so a future // optimization could potentially throw away everything except for the final call. This would break // the perf test. The JitOptimizeCanary code below does modify the inputs and consume each output. result = Vector2.Normalize(result); } return(result); }
public void Vector2ReflectTest() { Vector2 a = Vector2.Normalize(new Vector2(1.0f, 1.0f)); // Reflect on XZ plane. Vector2 n = new Vector2(0.0f, 1.0f); Vector2 expected = new Vector2(a.X, -a.Y); Vector2 actual = Vector2.Reflect(a, n); Assert.True(MathHelper.Equal(expected, actual), "Vector2f.Reflect did not return the expected value."); // Reflect on XY plane. n = new Vector2(0.0f, 0.0f); expected = new Vector2(a.X, a.Y); actual = Vector2.Reflect(a, n); Assert.True(MathHelper.Equal(expected, actual), "Vector2f.Reflect did not return the expected value."); // Reflect on YZ plane. n = new Vector2(1.0f, 0.0f); expected = new Vector2(-a.X, a.Y); actual = Vector2.Reflect(a, n); Assert.True(MathHelper.Equal(expected, actual), "Vector2f.Reflect did not return the expected value."); }
internal PrismaticJoint(PrismaticJointDef def) : base(def) { LocalAnchorA = def.LocalAnchorA; LocalAnchorB = def.LocalAnchorB; LocalXAxisA = def.LocalAxisA; LocalXAxisA.Normalize(); _localYAxisA = MathUtils.Cross(1.0f, LocalXAxisA); ReferenceAngle = def.ReferenceAngle; _impulse.SetZero(); _motorMass = 0.0f; _motorImpulse = 0.0f; _lowerTranslation = def.LowerTranslation; _upperTranslation = def.UpperTranslation; _maxMotorForce = def.MaxMotorForce; _motorSpeed = def.MotorSpeed; _enableLimit = def.EnableLimit; _enableMotor = def.EnableMotor; _limitState = LimitState.InactiveLimit; _axis.SetZero(); _perp.SetZero(); }