Created
October 20, 2013 21:26
-
-
Save DieHertz/7075546 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
mat3 Transform::rotate(const float degrees, const vec3& axis) { | |
const float cosine = glm::cos(glm::radians(degrees)); | |
const float one_minus_cosine = 1.0f - cosine; | |
const float sine = glm::sin(glm::radians(degrees)); | |
return glm::mat3(axis.x * axis.x * one_minus_cosine + cosine, | |
axis.x * axis.y * one_minus_cosine + axis.z * sine, | |
axis.x * axis.z * one_minus_cosine - axis.y * sine, | |
axis.y * axis.x * one_minus_cosine - axis.z * sine, | |
axis.y * axis.y * one_minus_cosine + cosine, | |
axis.y * axis.z * one_minus_cosine + axis.x * sine, | |
axis.z * axis.x * one_minus_cosine + axis.y * sine, | |
axis.z * axis.y * one_minus_cosine - axis.x * sine, | |
axis.z * axis.z * one_minus_cosine + cosine); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment