Advertisement
Drakia

Untitled

Apr 8th, 2011
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.40 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.atan2(distX, distZ)) - 90;
  9.            
  10.             if (degrees < 0) degrees += 360;
  11.             degrees %= 360;
  12.         return degrees;
  13.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement