Advertisement
Drakia

Untitled

Apr 8th, 2011
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.48 KB | None | 0 0
  1.     /**
  2.      * Gets the Yaw from one location to another in relation to North.
  3.      *
  4.      */
  5.     public double getYawTo(Location from, Location to) {
  6.             final int distX = to.getBlockX() - from.getBlockX();
  7.             final int distZ = to.getBlockZ() - from.getBlockZ();
  8.             double degrees = Math.toDegrees(Math.atan(distX/distZ));
  9.             if ( (distX < 0 && distZ >= 0) || ( distX >= 0 && distZ >= 0) )
  10.                     degrees += 180;
  11.             if ( distX >= 0 && distZ < 0)
  12.                 degrees += 360;
  13.            
  14.         return degrees;
  15.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement