PO_matlab
mycart2sph.m File Reference

Converts Cartesian coordinates to spherical coordinates. More...

Functions

function mycart2sph (in x, in y, in z)

Detailed Description

Converts Cartesian coordinates to spherical coordinates.

Given Cartesian coordinates (x, y, z), this function computes the corresponding spherical coordinates: radial distance r, elevation angle theta, and azimuthal angle phi. Handles edge cases such as r = 0 to avoid NaN values in theta.

Parameters
xX-coordinate(s)
yY-coordinate(s)
zZ-coordinate(s)
Return values
rRadial distance(s) from the origin
thetaElevation angle(s) [rad], 0 along +z
phiAzimuthal angle(s) [rad], 0 along +x

Function Documentation

◆ mycart2sph()

function mycart2sph ( in x,
in y,
in z )