MATLAB: Visualise direction 3D vector defined by two angles

3d vector defined by two angles

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!

Best Answer

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)
Related Question