Why converting from Spherical to Cartesian using the command "sph2cart" gives different values than converting it manually by writing the equations of each coordinate?

 Akzeptierte Antwort

Assuming theta is azimuth and phi is elevation, your equations would be (from the documentation):
x = r .* cos(phi) .* cos(theta)
y = r .* cos(phi) .* sin(theta)
z = r .* sin(phi)
Making those corrections gives:
r = 10;
theta = pi/4;
phi = pi/3;
x = r*cos(phi)*cos(theta)
x = 3.5355
y = r*cos(phi)*sin(theta)
y = 3.5355
z = r*sin(phi)
z = 8.6603
And note that the order of the inputs to sph2cart is azimuth before elevation:
[x,y,z] = sph2cart(theta,phi,r)
x = 3.5355
y = 3.5355
z = 8.6603

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 7 Sep. 2024

Beantwortet:

am 7 Sep. 2024

Community Treasure Hunt

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

Start Hunting!

Translated by