Rotation

glRotate()

Rotation is setup in the top left part of a matrix so only the 3x3 part is shown here for each matrix.

Rotation θ around a axis

x =| 1 0 0 |

| 0 cos(θ) -sin(θ) |

| 0 sin(θ) cos(θ) |

y =| cos(θ) 0 sin(θ) |

| 0 1 0 |

| -sin(θ) 0 cos(θ) |

z =| cos(θ) -sin(θ) 0 |

| sin(θ) cos(θ) 0 |

| 0 0 1 |

Rotation θ around a arbitrary axis R

c = cos(θ) and s = sin(θ). R is the normalized axis of rotation.

r = | c+(1-c)Rx2 (1-c)RxRy-sRz (1-c)RxRz+sRy |

| (1-c)RxRy+sRz c+(1-c)Ry2 (1-c)RyRz-sRx |

| (1-c)RxRz-sRy (1-c)RyRz+sRx c+(1-c)Rz2 |

Rotating a vector using integer math - 2018

Math for Game Programmers: Working with 3D Rotations - 2014

Understanding Rotations - 2012

Rotations And Infinitesimal Generators - 2011

Three Dimensional Rotations - 2001

3D Rotation

Euler Angles are Evil.