Advertisement
Guest User

Untitled

a guest
Apr 10th, 2020
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.26 KB | None | 0 0
  1. private double addLatitude(double base, double offset) {
  2.         double newLatitude = base + offset;
  3.         if (newLatitude <= LATITUDE_BOUND) {
  4.             return newLatitude;
  5.         } else {
  6.             return -(crossBound(newLatitude, LATITUDE_BOUND));
  7.         }
  8.     }
  9.  
  10.     private double subtractLatitude(double base, double offset) {
  11.         double newLatitude = base - offset;
  12.         if (newLatitude >= -LATITUDE_BOUND) {
  13.             return newLatitude;
  14.         } else {
  15.             return crossBound(newLatitude, LATITUDE_BOUND);
  16.         }
  17.     }
  18.  
  19.     private double addLongitude(double base, double offset) {
  20.         double newLongitude = base + offset;
  21.         if (newLongitude <= LONGITUDE_BOUND) {
  22.             return newLongitude;
  23.         } else {
  24.             return crossBound(newLongitude, LONGITUDE_BOUND);
  25.         }
  26.     }
  27.  
  28.     private double subtractLongitude(double base, double offset) {
  29.         double newLongitude = base - offset;
  30.         if (newLongitude >= -LONGITUDE_BOUND) {
  31.             return newLongitude;
  32.         } else {
  33.             return -(crossBound(newLongitude, LONGITUDE_BOUND));
  34.         }
  35.     }
  36.  
  37.     private double crossBound(double newValue, double bound) {
  38.         return bound - (Math.abs(newValue) - bound);
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement