Skip to content

Instantly share code, notes, and snippets.

@jarcode-foss
Last active January 20, 2016 04:06
Show Gist options
  • Save jarcode-foss/1c61ae1a6ce0d4bcf6fe to your computer and use it in GitHub Desktop.
Save jarcode-foss/1c61ae1a6ce0d4bcf6fe to your computer and use it in GitHub Desktop.
/* '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