# rotation of spherical surface in spherical coordinates

I need to plot a spherical surface in computer (like the surface of a lens). I know the normal vector (as an example, say $\ n=(1,2,3)$) of this surface and it originates from the centre of the surface. Since this surface is oriented along an arbitary direction defined by $\ n$, I don't know how to plot it, but I do know how to plot such a surface if its surface normal at the centre points along the z-axis, as shown in the attached diagram (as the polar and azimuthal angle that define the surface become much easier to calculate and implement in a program).

Now my actual problem is that given the cartesian coordinates of all the points on the surface (that is oriented along the z-axis), what is the rotation matrix (or other mathematical object) that can transform this surface to the actual surface I want (defined by $\ n$)?

• I'm a little confused by what you're asking, but I think you are essentially asking for the rotation matrix that takes the z-axis to the n-axis? – user226970 Jan 14 '16 at 23:54
• yes, you are right – Physicist Jan 15 '16 at 9:12
• Here is a sketch: normalize the cross product $\hat{n} \times \hat{z}$ to find the vector perpendicular to both. This is the axis of the rotation. The angle is given of course by $\sin^{-1}( | \hat{n} \times \hat{z} | )$ and by $\cos^{-1}( \hat{n} \cdot \hat{z} )$. Then use the formulas given here: en.wikipedia.org/wiki/…. It should simplify considerably, but I did not work out the algebra. Tell me if you get stuck. – user226970 Jan 15 '16 at 23:42