How can I calculate and plot a 3D pointing vector from a 2D azimuth and elevation angle?
29 views (last 30 days)
I have a list of azimuths and starting locations, which I use to compute an end location, then I plot the line as a pointing vector.
For every azimuth, I also have an elevation angle from 0 to 180 degrees (0 is straight down and 180 is straight up).
I essentially want to have my 2D pointing vector, and change it's 3D angle based on the elevation angle so that I end up with a 3D pointing vector.
I have this code that I wrote to get a 2D vector from the initial x and y starting points, as well as the initial 2D azimuth. This draws line of length 5 at 90 degrees clockwise from the north, now I want this line to be in 3D and 20 degrees up from vertical down. I can't figure out how to integrate the elevation angle to compute a 3D vector.
%test 2D to 3D pointing vectors
x1=2; %initial x position
y1=2; %initial y position
az2d=90; %degrees clockwise from 0 north
az_elevation=20; %degrees up from Z-down
L=5; %line length
x2=x1+(L*cosd(90-az2d)); %end x position calculated from initial and azimuth; matlab plotting angles is 90-angle (e.g. 90-degrees clockwise from north needs 90-90 as input)
y2=y1+(L*sind(90-az2d)); %end y position calculated from initial and azimuth; matlab plotting angles is 90-angle (e.g. 90-degrees clockwise from north needs 90-90 as input)
plot([x1 x2], [y1 y2])