public void GetPolarCoordinates_Test() { var point = new Vector3(3, 4, 5); var polarCoordinates = DegreesRadiansConverter.TransformToPolarCoordinates(point); double[] expectedValues = { 7.0710678118655, 0.92729521800161, 0.78539816339745 }; double epsilon = 1e-5; Assert.IsTrue(Math.Abs(expectedValues[0] - polarCoordinates.X) < epsilon); Assert.IsTrue(Math.Abs(expectedValues[1] - polarCoordinates.Y) < epsilon); Assert.IsTrue(Math.Abs(expectedValues[2] - polarCoordinates.Z) < epsilon); }
public void GetCartesianCoordinates_Test() { var point = new Vector3(3, 4, 5); var polarCoordinates = DegreesRadiansConverter.TransformToPolarCoordinates(point); var recalculatedPoint = DegreesRadiansConverter.TransformToCartesianCoordinates(polarCoordinates.X, polarCoordinates.Y, polarCoordinates.Z); double epsilon = 1e-8; Assert.IsTrue(Math.Abs(recalculatedPoint.X - point.X) < epsilon); Assert.IsTrue(Math.Abs(recalculatedPoint.Y - point.Y) < epsilon); Assert.IsTrue(Math.Abs(recalculatedPoint.Z - point.Z) < epsilon); }