Coverage for navipy/maths/coordinates.py : 70%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" Conversion between coordinates systems """
""" Cartesian to spherical coordinates
:param x: position along x-axis :param y: position along y-axis :param z: position along z-axis :returns: elevation,azimuth,radius
inverse transform of : x = radius*cos(elevation) * cos(azimuth) y = radius*cos(elevation) * sin(azimuth) z = radius*sin(elevation)
""" radius = np.sqrt(x**2 + y**2 + z**2) elevation = np.arctan2(z, np.sqrt(x**2 + y**2)) azimuth = np.arctan2(y, x) spherical = np.zeros_like(x) spherical = np.tile(spherical[..., np.newaxis], (3,)) return elevation, azimuth, radius
"""Spherical to cartesian coordinates
:param elevation: elevation :param azimuth: azimuth :param radius: radius :returns: x,y,z
transform : x = radius*cos(elevation) * cos(azimuth) y = radius*cos(elevation) * sin(azimuth) z = radius*sin(elevation) """
"""Now we need the cartesian vector as a spherical vecotr. A vector in cartesian coordinates can be transform as one in the spherical coordinates following the transformation:
A_rho =+A_x.*cos(epsilon).*cos(phi) +A_y.*cos(epsilon).*sin(phi) +A_z.*sin(epsilon) A_epsilon=-A_x.*sin(epsilon).*cos(phi) -A_y.*sin(epsilon).*sin(phi) +A_z.*cos(epsilon) A_phi =-A_x.*sin(phi)+A_y.*cos(phi)
for epsilon in [-pi/2 +pi/2] and phi in [0 2pi] reverse tajectory, needed because the frame x,y,z is expressed in the orientation Yaw=pitch=roll=0""" raise ValueError("cartesian vector must not be None") raise ValueError("viewing direction must not be None") raise TypeError("vector must be of type np.ndarray") raise Exception("first dimension of cartesian vector\ must have size three") raise TypeError("cartesian vector must be of numerical type") (not isinstance(viewing_direction, np.ndarray)): raise TypeError("angles must be list or np.ndarray") raise TypeError("viewing_direction must be of numerical type") raise Exception("first dimension of viewing\ direction must be of size two")
|