This small utility will help you to convert degree to radians and radians to degree for mathematical operations. there is two separate functions for each. use as per your requirement.
public static float ToDegrees(float radians)
{
// This method uses double precission internally,
// though it returns single float
// Factor = 180 / pi
return (float) (radians * 57.295779513082320876798154814105);
}
public static float ToRadians(float degrees)
{
// This method uses double precission internally,
// though it returns single float
// Factor = pi / 180
return (float) (degrees * 0.017453292519943295769236907684886);
}
No comments:
Post a Comment