Skip to content

Instantly share code, notes, and snippets.

@yiwenl
Created November 13, 2019 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yiwenl/daa1dfa3fba1362e1c86c66079d52cf6 to your computer and use it in GitHub Desktop.
Save yiwenl/daa1dfa3fba1362e1c86c66079d52cf6 to your computer and use it in GitHub Desktop.
vec3 align(vec3 pos, vec3 dir) {
vec3 initDir = vec3(1.0, 0.0, 0.0);
vec3 axis = cross(dir, initDir);
float angle = acos(dot(dir, initDir));
return rotate(pos, axis, angle);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment