![]() |
Function to transform Cartesian coordinates to spherical coordinates.
tfg.math.math_helpers.cartesian_to_spherical_coordinates(
point_cartesian, eps=None, name='cartesian_to_spherical_coordinates'
)
This function assumes a right handed coordinate system with z
pointing up.
When x
and y
are both 0
, the function outputs 0
for phi
. Note that
the function is not smooth when x = y = 0
.
Note:
In the following, A1 to An are optional batch dimensions.
Args | |
---|---|
point_cartesian
|
A tensor of shape [A1, ..., An, 3] . In the last
dimension, the data follows the x , y , z order.
|
eps
|
A small float , to be added to the denominator. If left as None , its
value is automatically selected using point_cartesian.dtype .
|
name
|
A name for this op. Defaults to "cartesian_to_spherical_coordinates". |
Returns | |
---|---|
A tensor of shape [A1, ..., An, 3] . The last dimensions contains
(r ,theta ,phi ), where r is the sphere radius, theta is the polar
angle and phi is the azimuthal angle. Returns NaN gradient if x = y = 0.
|