When we create a 3D scene and manipulate its objects, we usually need to rotate them in order to properly place and orient them among other objects. Rotating an object is achieved with a rotation matrix. For it, we need to specify a vector, around which rotation will be performed, and an angle--how much rotation we want to apply.
Preparing a rotation matrix
How to do it...
- Prepare three variables of type float named x, y, and z. Initialize them with values that define an arbitrary vector, around which rotation should be performed. Make sure the vector is normalized (has a length equal to 1.0f).
- Prepare a variable of type float named angle and store an angle of the rotation (in radians) in it.
- Create a variable of type float named c. Store a cosine of the angle in...