Skip to content

Instantly share code, notes, and snippets.

@vurtun
Created June 13, 2017 11:58
Show Gist options
  • Save vurtun/ec13abcfa23eb86feaa36e26feb0c055 to your computer and use it in GitHub Desktop.
Save vurtun/ec13abcfa23eb86feaa36e26feb0c055 to your computer and use it in GitHub Desktop.
struct quat
quat_from_two_vectors(vec3 u, vec3 v)
{
float m = sqrt(2.f + 2.f * dot(u, v));
vec3 w = (1.f / m) * cross(u, v);
return quat(0.5f * m, w.x, w.y, w.z);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment