# azimuth, elevation to x y z rotation

67 views (last 30 days)
Henning Wilhelm on 25 May 2022
Edited: Benjamin Thompson on 25 May 2022
Hello,
input for my rotation is azimuth and elevation. I want to have the rotation for x y and z from this to rotate my 3D data.
example:
gm = multicuboid(0.3,0.3,0.3); %create cube 30cm*30cm*30cm
cube_coordinates = gm.Vertices; %copy coordinates from cube
az = 45; %azimuth angle = 45°
el = 0; %elevation angle = 0°
%[x,y,z] = azel2xyz(az,el);
%rotMat = rotx(x) * roty(y) * rotz(z); %create rotation matrix with azimuth angle of 45°
rotMat = rotx(0) * roty(0) * rotz(45); %create rotation matrix with azimuth angle of 45°
cube_coordinates_rot = rotMat*cube_coordinates'; % apply rotation matrix
cube_coordinates_rot = cube_coordinates_rot';
figure
subplot(1,2,1)
scatter3(cube_coordinates(:,1),cube_coordinates(:,2),cube_coordinates(:,3));
title('unrotated');
subplot(1,2,2)
scatter3(cube_coordinates_rot(:,1),cube_coordinates_rot(:,2),cube_coordinates_rot(:,3));
title('rotated');
I'm looking for a solution for the function [x,y,z] = azel2xyz(az,el);
I tried sph2cart without any success.

Benjamin Thompson on 25 May 2022
Edited: Benjamin Thompson on 25 May 2022
Your question is incomplete. Azimuth and elevation are two angles and there is no single point solution [x, y, z] that satisfies the equation [x,y,z] = azel2xyz(az,el) unless you add a third parameter for range.
For some background information google "Discrete Cosine Transform" and if you have access to the aerospace toolbox look over the documentation for the angle2dcm function. Also google "Euler Angles".
Then if you do something like:
dcm = angle2dcm(45*pi/180, 20*pi/180, 0, 'ZYX');
p2 = dcm*[range 0 0]';
Then this would convert a point [range 0 0] in the initial "1" coordinate frame to point p2 in the "2" coordinate frame where "2" is rotated counter clockwise 45 degrees in Z and then counter clockwise 20 degrees in Y compared to "1" following right hand rule coordinate conventions and Euler's definition of orientation angles.