# Rotation matrix for azimuth and zenith angles

1. Jun 23, 2010

### lightningbolt

I have a shape with spherical coordinate (r, theta, phi) which I can convert to Cartesian. I want to apply rotation to the shape by incrementing theta & phi.
I figured out the matrix for rotating azimuth angle is
{
{cos(theta), -sin(theta), 0}
{sin(theta), cos(theta), 0}
{ 0, 0, 1}
}
How to find the rotation matrix for Zenith angle?.
Thanks.

2. Jun 25, 2010

Why don't you increment θ and φ as you wish then convert to Cartesian?

3. Jun 25, 2010

### lightningbolt

If you change θ and φ in spherical coordinates and convert to Cartesian, it wont result in the change you expect. It gives garbage values.
i.e I cant just add 5 degree to θ or φ, if i want to rotate the shape 5 degree.
Thanks.

4. Jun 25, 2010

I don't think I understand what you're after.

If it is rotation equations inside a Cartesian system you're after:

v1 = calf*xi+salf*zi;
v2 = calf*zi-salf*xi;
v3 = cbet*yi+sbet*v2;

zr = cbet*v2-sbet*yi;
xr = cgam*v1+sgam*v3;
yr = cgam*v3-sgam*v1;

salf = $$\sin(\alpha)$$;
calf = $$\cos(\alpha)$$;

etc.

In case you're making a mistake converting to Cartesian, I've worked out how to do it and http://en.wikipedia.org/wiki/Spherical_coordinate_system#Cartesian_coordinates":

x = radius · sin(θ) · cos(φ)
y = radius · sin(θ) · sin(φ)