Visualise direction 3D vector defined by two angles

3 views (last 30 days)
I'm an almost complete MatLab novice, and would like to visualise in 3D the direction of a vector defined by two angles. Specifically, I have (1) a 'frontal' plane angle (in degrees- as if looking from the front), where 0 degrees is along the conventional x-axis, positive angle is defined in the clockwise direction, and (2) a 'horizontal' plane angle (in degrees- as if looking from above), where 0 degrees is again along the x-axis, positive angle defined in the clockwise direction such that +90 is orthogonal to the frontal plane.
I have been trying to write a basic script that will show an arrow from the origin to the direction of the vector (magnitude is not important)- I suspect it is trivial but I have been failing!

Accepted Answer

Matt J
Matt J on 22 Jul 2019
Edited: Matt J on 22 Jul 2019
How about something like this,
[u,v,w]=sph2cart(-angle1*pi/180 , pi/2-angle2*pi/180, 1);
quiver3(0,0,0,u,v,w)
  2 Comments
Matt J
Matt J on 22 Jul 2019
Henry’s reply moved here:
That works great- thank you!
Matt J
Matt J on 22 Jul 2019
You are welcome, but since it worked please Accept-click the answer.

Sign in to comment.

More Answers (0)

Categories

Find more on Dates and Time in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!