MATLAB: How to calculate direction in rotated coordinate system

coordinate system rotationdirection

I have a direction defined by azimuth and evation (e.g. Azi, Elev).
I would like to calculate values of these Azi i Elev after coordinate system
rotation: first around Z axis (angle e.g.: Zrot) and then around rotated (in first rotation
around Z axis) Y axis (angle e.g.: Yrot).
So: I rotate coordinate system around Z axis, then around "rotated" Y axis and I would like to
calculate Azi and Elev in rotated coordinate system.
How can be it done?

Best Answer

Hi UWM,
Assuming the correct rotation has already been made, then calling the resulting vector u, and making sure it is normalized by using u/norm(u), suppose the three components of u are given in the order (north,east, up) in an appropriate coordinate system. Assuming elevation is measured up from the horizon and azimuth is measured clockwise from north (as with a compass rose), u has the form
cos(el)*cos(az)
cos(el)*sin(az)
sin(el)
then you can divide the second expression by the first to arrive at
el = asin(u(3))
az = atan2(u(2)/u(1)
There are a lot of variations on this theme depending on how the vector components and the angles are defined, but the basic idea will be the same.