using System;
public static class AngleUtility
{
public static double ToDegree(this double radian)
{
return radian * 180 / Math.PI;
}
public static double ToRadian(this double degree)
{
return degree * Math.PI / 180;
}
public static double NormalizeAngleDegree(this double degree)
{
if (degree >= 0.0)
{
while (degree >= 180.0)
{
degree -= 360.0;
}
}
else
{
while (degree < -180.0)
{
degree += 360.0;
}
}
return degree;
}
public static double NormalizeAngleRadian(this double radian)
{
if (radian >= 0.0)
{
while (radian >= Math.PI)
{
radian -= Math.PI * 2;
}
}
else
{
while (radian < -Math.PI)
{
radian += Math.PI * 2;
}
}
return radian;
}
}