Skip to content

Instantly share code, notes, and snippets.

@RaasAhsan
Created November 16, 2012 04:14
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save RaasAhsan/4083992 to your computer and use it in GitHub Desktop.
pitch/yaw to directional vector
// pitch and yaw are in degrees
Vector3D getDirectionVector() {
return new Vector3D(-Math.cos(pitch * Math.PI / 180.0) * Math.sin(yaw * Math.PI / 180.0), Math.sin(pitch * Math.PI / 180.0), -Math.cos(pitch * Math.PI / 180.0) * Math.cos(yaw * Math.PI / 180.0));
}
@SnowRunescape
Copy link

SnowRunescape commented Aug 30, 2019

hey, I used the code, but there is a small error, below the solution

Vector3D getDirectionVector() { return new Vector3D(Math.cos(pitch * Math.PI / 180.0) * Math.sin(yaw * Math.PI / 180.0), Math.sin(pitch * Math.PI / 180.0), -Math.cos(pitch * Math.PI / 180.0) * Math.cos(yaw * Math.PI / 180.0)); }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment