Вопрос

I'm getting confused with the variety of names for angles in Spherical Coordinates. According to Matlab documentation that "azimuth and elevation are angular displacements in radians. azimuth is the counterclockwise angle in the x-y plane measured from the positive x-axis. elevation is the elevation angle from the x-y plane. r is the distance from the origin to a point."

Ok, I will call azimuth angle as Theta and elevation angle as Phi. Now, I want to build a function that convert Cartesian to Spherical. This is what I did

function [y] = my_car2sph(x)
    d = sqrt(x(1)^2 + x(2)^2 + x(3)^2);
  Phi = acos(x(3)/d);   % elevation angle 
Theta = atan2(x(2),x(1)); % azimuth
y = [d; Theta; Phi];

Now, the output of this function

>> my_car2sph([1; 1; 1])

ans =

    1.7321   <--- d
    0.7854   <--- Theta (azimuth)
    0.9553   <--- Phi (elevation)

Now, if I use the Matlab's function, this is what I'm getting

>> [azimuth,elevation,r] = cart2sph(1,1,1)

azimuth =

    0.7854


elevation =

    0.6155


r =

    1.7321

>> 

Why the elevation angle (Phi) is not the same?

Это было полезно?

Решение

your definition of the angle Phi defines it with respect to the vertically up direction, so it varies from 0 to 180 degrees (called Colatitude). Matlab measures that vertical angle from x-y plane, so it varies from -90 to +90 degrees (Latitude). For these sort of applications, I would suggest using degrees not radians to not get confused. So if you do Phi = asin(x(3)/d), you get the same result as Matlab.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top