I want to program a subroutine that randomizes an angle and rotates some coordinates in 3D by that angle. The rotation matrices are already working, so the mathematics are not the problem. I'll have to do that a couple of hundred times to a couple of hundred thousand times, so right now I'm thinking of how to optimize the code. On the one hand I could randomize the sine of the angle and calculate the cosine (both needed for rotation matrices) using the following relation:
On the other hand I could randomize the angle and calculate both sine and cosine from the angle.
How can I find out which option is more efficient?