License Public Domain
Lines 12
Keywords
geometry (2)
Permissions
Owner: Stou S.
Viewable by Everyone
Editable by All Siafoo Users
Hide
Siafoo – the intersection of pastebin, help desk, version control, and social networking Join Siafoo Now or Learn More

Rotation Matrix Atom Feed 0

In Brief A simple implementation of a 3D rotation matrix. It rotates the point loc by angle degrees around the axis uX, uY, uZ.
# 's
 1void rotate(float angle, float uX, float uY, float uZ, float loc[])
2{
3 // This is probably an unnecessary optimization
4 float c = cos(radians(angle));
5 float s = sin(radians(angle));
6
7 float x = loc[0];
8 float y = loc[1];
9 float z = loc[2];
10
11 loc[0] = x*(uX*uX*(1 - c) + c) + y*(uX*uY*(1 - c) - uZ*s) + z*(uX*uZ*(1 - c) + uY*s);
12 loc[1] = x*(uX*uY*(1 - c) + uZ*s) + y*(uY*uY*(1 - c) + c) + z*(uY*uZ*(1 - c) - uX*s);
13 loc[2] = x*(uX*uZ*(1 - c) - uY*s) + y*(uY*uZ*(1 - c) + uX*s) + z*(uZ*uZ*(1 - c) + c);
14
15}

A simple implementation of a 3D rotation matrix. It rotates the point loc by angle degrees around the axis uX, uY, uZ.