//************************************************************************************************ // //************************************************************************************************ static public float NormalizeRad(float angle, NORM norm, GPS.TYPE type = GPS.TYPE.LONGITUDE) { int revs = ( int )(angle / PI_MUL2); angle -= (( float )revs * PI_MUL2); if (angle < 0.0f) { angle += PI_MUL2; } if ((norm == NORM.NEG) && (angle > PI)) { angle -= PI_MUL2; } if (type == GPS.TYPE.LATITUDE) { if (angle > PI_34) { angle = -PI_MUL2 + angle; } else if (angle > PI) { angle = -PI + angle; } else if (angle > PI_DIV2) { angle = PI - angle; } else if (angle < -PI_DIV2) { angle = -PI - angle; } } return(angle); }
//************************************************************************************************ // //************************************************************************************************ static public float NormalizeDeg(float angle, NORM norm, GPS.TYPE type = GPS.TYPE.LONGITUDE) { int revs = ( int )(angle / 360.0f); angle -= (( float )revs * 360.0f); if (angle < 0.0f) { angle += 360.0f; } if ((norm == NORM.NEG) && (angle > 180.0f)) { angle -= 360.0f; } if (type == GPS.TYPE.LATITUDE) { if (angle > 270.0f) { angle = -360.0f + angle; } else if (angle > 180.0f) { angle = -180.0f + angle; } else if (angle > 90.0f) { angle = 180.0f - angle; } else if (angle < -90.0f) { angle = -180.0f - angle; } } return(angle); }
//************************************************************************************************ // //************************************************************************************************ static public float Normalize(float angle, UNIT unit, NORM norm, GPS.TYPE type = GPS.TYPE.LONGITUDE) { return(NormalizeFunc[( int )unit](angle, norm, type)); }