Created
June 13, 2017 11:58
-
-
Save vurtun/ec13abcfa23eb86feaa36e26feb0c055 to your computer and use it in GitHub Desktop.
This file contains 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
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