To account for multiple scatterings along the trajectory of a particle, it is necessary to calculate the components of the scattered momentum in terms of the incident momentum and the scattering angles.
In three dimensions, any vector's direction is uniquely defined by two angles. (Only two coordinates are necessary to cover the surface of the sphere.) Thus it is only necessary to deal with two types of rotations. For conventional reasons, we will perform rotations about the y and z axes.
Rotations can be represented by 3x3 matrices acting on 3-component vectors. Given Ry(θ) and Rz(φ), it is simple to calculate an arbitrary unit vector. These matrices and the algebra associated with them represent the group SO(3), but if this language troubles you, then just disregard it.
Rotation about an arbitrary axis can be performed by clever use of the two rotation matrices already given. Define the axis of rotation by θ and φ as they have been used already. Consider a rotation about this axis by the angles θ' and φ'. If we first rotate the y' axis to the original y axis, then we can perform the desired rotation by φ' about the y axis and finally return the y' axis to where it belongs.
The same procedure can be used for the azimuthal rotation about our arbitrary axis, but it will need to be derotated and rerotated using both matrices.
Putting these results together and simplifying everything gives the equation for the arbitrary rotation.
Just to give the result in concrete form, the initial vector is n0 with components x0, y0, and z0:
The rotation by δn has components δx, δy, and δz:
Then the final vector has the following components:
(θ and φ are the angles that define n0.) That's about all there is to rotating vectors in three dimensions.