NormalizeAngle.java 629B

123456789101112131415161718192021222324252627
  1. public class NormalizeAngle {
  2. private Integer newAngle;
  3. public Integer normalizeValueUsingModulo(Integer angle){
  4. // reduce the angle
  5. newAngle = angle % 360;
  6. // force into the minimum absolute value residue class, so that -180 < angle <= 180
  7. if (newAngle > 360) {
  8. newAngle -= 360; }
  9. else if(newAngle < 0) {newAngle += 360;}
  10. return newAngle;
  11. }
  12. public Integer normalizeValueUsingFloorMod(Integer integer){
  13. newAngle = Math.floorMod(integer, 360);
  14. return newAngle;
  15. }
  16. public static void main(String[] args){
  17. }
  18. }