Last active
January 20, 2016 04:06
-
-
Save jarcode-foss/1c61ae1a6ce0d4bcf6fe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 'eye' is the location of */ | |
double yaw = eye.getYaw() > 0 ? eye.getYaw() : 360 - Math.abs(eye.getYaw()); // remove negative degrees | |
yaw += 90; // rotate +90 degrees | |
if (yaw > 360) | |
yaw -= 360; | |
yaw = (yaw * Math.PI) / 180; | |
double pitch = ((eye.getPitch() + 90) * Math.PI) / 180; | |
// player-space | |
double xp = Math.sin(pitch) * Math.cos(yaw); | |
double zp = Math.sin(pitch) * Math.sin(yaw); | |
double yp = Math.cos(pitch); | |
// if you need it, this is world-space | |
xp += eye.getX(); | |
xy += eye.getY(); | |
xz += eye.getZ(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment