Created
December 5, 2013 18:03
-
-
Save BitPuffin/7810239 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
proc rotate(axis: TVector, angle: float): TMat4 = | |
let cosine = cos(angle).float32 | |
let sine = sin(angle).float32 | |
let oneminuscos = 1 - cosine | |
let xsquared = axis[0].pow(2.0) | |
let ysquared = axis[1].pow(2.0) | |
let zsquared = axis[2].pow(2.0) | |
result = [[cosine + oneminuscos*xsquared, oneminuscos*axis[0]*axis[1] - axis[2]*sine, oneminuscos*axis[0]*axis[2] + axis[1]*sine, 0], | |
[oneminuscos*axis[0]*axis[1] + axis[2]*sine, cosine + oneminuscos*ysquared, oneminuscos*axis[1]*axis[2] - axis[0]*sine, 0], | |
[oneminuscos*axis[0]*axis[2] - axis[1]*sine, oneminuscos*axis[1]*axis[2] + axis[0]*sine, cosine + oneminuscos*zsquared, 0], | |
[0f32, 0f32, 0f32, 1f32]] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment