Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Gets the Yaw from one location to another in relation to North.
- *
- */
- public double getYawTo(Location from, Location to) {
- final int distX = to.getBlockX() - from.getBlockX();
- final int distZ = to.getBlockZ() - from.getBlockZ();
- double degrees = Math.toDegrees(Math.atan(distX/distZ));
- if ( (distX < 0 && distZ >= 0) || ( distX >= 0 && distZ >= 0) )
- degrees += 180;
- if ( distX >= 0 && distZ < 0)
- degrees += 360;
- return degrees;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement