All you need to create a rotational matrix is ββa step, yaw, roll and the ability to perform matrix multiplication.
First create three rotational matrices, one for each axis of rotation (i.e. one for pitch, one for yaw, one for roll). These matrices will have values:
Pitch Matrix:
1, 0, 0, 0, 0, cos(pitch), sin(pitch), 0, 0, -sin(pitch), cos(pitch), 0, 0, 0, 0, 1
Yaw Matrix:
cos(yaw), 0, -sin(yaw), 0, 0, 1, 0, 0, sin(yaw), 0, cos(yaw), 0, 0, 0, 0, 1
Roller Matrix:
cos(roll), sin(roll), 0, 0, -sin(roll), cos(roll), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1
Then, multiply everything together. The order is important here. For normal rotations, you first want to multiply the Roll matrix by the Yaw matrix, and then multiply the product by the pitch matrix. However, if you try to βreverseβ a rotation by reversing, you will want to multiply in the reverse order (in addition to angles with opposite values).