本文介绍了从笛卡尔转换为球形Matlab?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对球坐标中各种角度的名称感到困惑.根据Matlab文档,方位角和标高是弧度的角位移.方位角是xy平面中从正x轴开始测量的逆时针角度.标高是从xy平面到仰角的角度.r是从原点到基准点的距离.一个点."

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."

好吧,我将方位角称为Theta,将仰角称为Phi.现在,我想构建一个将笛卡尔坐标转换为球形的函数.这就是我所做的

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];

现在,此函数的输出

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

ans =

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

现在,如果我使用Matlab的功能,这就是我要得到的

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

>>

为什么仰角(Phi)不同?

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

推荐答案

您对角度Phi的定义是相对于垂直向上的方向定义的,因此它的范围为0到180度(称为Colatitude). Matlab测量与x-y平面的垂直角度,因此它在-90到+90度(纬度)之间变化.对于此类应用程序,我建议您使用度数(而不是弧度)以免混淆.因此,如果执行Phi = asin(x(3)/d),您将获得与Matlab相同的结果.

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.

这篇关于从笛卡尔转换为球形Matlab?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 16:38