http://qs1969.pair.com?node_id=400097


in reply to Rotate a 3D vector

RX= 1 0 0
0 cos φ - sin φ
0 sin φ cos φ

RY= cos θ 0 sin θ
0 1 0
0 -sin θ cos θ

RZ= cos ψ -sin ψ 0
sin ψ cos ψ 0
0 0 1
Then your rotation matrix is RX * RY * RZ, with θ the amount of rotation around the X axis, φ the amount of rotation around the Y axis, and ψ the amount of rotation around the Z axis.