static public void TestSqrt() { //Basic tests AssertEquals(FMath.Sqrt(fint.CreateFromInt(0)), 0.0f); AssertEquals(FMath.Sqrt(fint.CreateFromInt(1)), 1.0f); AssertEquals(FMath.Sqrt(fint.CreateFromInt(4)), 2.0f); AssertAlmostEquals(FMath.Sqrt(fint.CreateFromInt(2)), 1.41421356237f); //Iterative test for (float f = 0; f < 1; f += 0.001f) { AssertAlmostEquals(FMath.Sqrt(fint.CreateFromFloat(f)), (float)Math.Sqrt(f)); } for (float f = 0; f < 100; f += 0.1f) { AssertAlmostEquals(FMath.Sqrt(fint.CreateFromFloat(f)), (float)Math.Sqrt(f)); } for (float f = 0; f < 100000; f += 100.0f) { AssertAlmostEquals(FMath.Sqrt(fint.CreateFromFloat(f)), (float)Math.Sqrt(f)); } }
public static fint Distance(FVector3 a, FVector3 b) { FVector3 vector = new FVector3(a.x - b.x, a.y - b.y, a.z - b.z); return(FMath.Sqrt(vector.x * vector.x + vector.y * vector.y + vector.z * vector.z)); }