Math API#
Angles and vectors#
angle()
#
dist()
#
cs()
#
- planetary_coverage.math.cs(angle)[source]#
Cosines and sines value of an angle (°).
- Parameters
angle (float or numpy.ndarray) – Input angle(s) (°).
- Returns
Cosine and Sines of this angle(s).
- Return type
Examples
>>> cs(0) 1, 0 >>> cs(45) 0.707..., 0.707...
lonlat()
#
- planetary_coverage.math.lonlat(xyz)[source]#
Convert cartesian coordinates into geographic coordinates.
- Parameters
xyz (numpy.ndarray) – XYZ cartesian vector.
- Returns
East Longitude [0°, 360°[ and North Latitude (°).
- Return type
Examples
>>> lonlat([1, 0, 0]) (0, 0) >>> lonlat([0, 1, 0]) (90, 0) >>> lonlat([1, 1, 0]) (45, 0) >>> lonlat([1, 0, 1]) (0, 45)
xyz()
#
- planetary_coverage.math.xyz(lon_e, lat, r=1)[source]#
Convert geographic coordinates in cartesian coordinates.
- Parameters
lon_e (float or numpy.ndarray) – Point(s) east longitude [0°, 360°[.
lat (float or numpy.ndarray) – Point(s) latitude [-90°, 90°].
r (float or numpy.ndarray, optional) – Point(s) distance/altitude [km].
- Returns
Cartesian coordinates.
- Return type
Examples
>>> xyz(0, 0) [1, 0, 0] >>> xyz(90, 0) [0, 1, 0] >>> xyz(45, 0) [0.707..., 0.707..., 0] >>> xyz(0, 45) [0.707..., 0, 0.707...]
vdot()
#
norm()
#
- planetary_coverage.math.vectors.norm(v)[source]#
Vector norm.
- Parameters
v (numpy.ndarray) – Input vector to measure(s).
- Returns
Input vector norm(s).
- Return type
Examples
>>> norm([1, 0, 0]) 1 >>> norm([1, 1, 1]) 1.732050...
hat()
#
- planetary_coverage.math.vectors.hat(v)[source]#
Normalize vector.
- Parameters
v (numpy.ndarray) – Input vector to normalize.
- Returns
Normalize input vector.
- Return type
Examples
>>> hat([1, 0, 0]) array([1., 0., 0.]) >>> hat([1, 1, 1]) array([0.577..., 0.577..., 0.577...])
Great circles#
great_circle()
#
great_circle_arc()
#
- planetary_coverage.math.great_circle_arc(lon_e_1, lat_1, lon_e_2, lat_2, npt=361)[source]#
Great circle arc coordinates between 2 anchor points.
Use Slerp interpolation.
- Parameters
- Raises
ValueError – If the two longitudes are on the same meridian (±180°).
great_circle_pole()
#
great_circle_path()
#
great_circle_patch()
#
Projections#
scalar_proj()
#
- planetary_coverage.math.vectors.scalar_proj(v, n)[source]#
Scalar projection.
s `n` o---|----> \ \ `v` x `v` · `n` s = --------- ||n||
- Parameters
v (list or numpy.ndarray) – Vector to project on the plane.
n (list or numpy.ndarray) – Plane normal vector.
- Returns
Scalar resolute of v in the direction of n.
- Return type
scalar_rejection()
#
- planetary_coverage.math.vectors.scalar_rejection(v, n)[source]#
Scalar rejection.
Orthogonal component u of the vector v in the plane of normal n. Also known as perpendicular dot product.
`n` o--------> |\ `u` | \ `v` v x `v` · `n` `u` = `v` - --------- `n` ||n|| p² = ||u||² = ||v||² - [(`v` · `n`) / ||n||]²
- Parameters
v (list or numpy.ndarray) – Vector to project on the plane.
n (list or numpy.ndarray) – Plane normal vector.
- Returns
Scalar resolute of v orthogonal to the direction of n.
- Return type
vector_rejection()
#
- planetary_coverage.math.vectors.vector_rejection(v, n)[source]#
Vector rejection.
Orthogonal vector u of the vector v in the plane of normal n.
`n` o--------> |\ `u` | \ `v` v x `v` · `n` `u` = `v` - --------- `n` ||n||
- Parameters
v (list or numpy.ndarray) – Vector(s) to project on the plane.
n (list or numpy.ndarray) – Plane normal vector.
- Returns
Scalar resolute of v orthogonal to the direction of n.
- Return type
Sphere functions#
hav_dist()
#
- planetary_coverage.math.hav_dist(lon_e_1, lat_1, lon_e_2, lat_2, r=1)[source]#
Calculate distance between 2 points on a sphere.
- Parameters
lon_e_1 (float or numpy.ndarray) – Point 1 east longitude (°).
lat_1 (float or numpy.ndarray) – Point 1 north latitude (°).
lon_e_2 (float or numpy.ndarray) – Point 2 east longitude (°).
lat_2 (float or numpy.ndarray) – Point 2 north latitude (°).
r (float, optional) – Planet radius.
- Returns
Haversine distance between the 2 points.
- Return type
sph_pixel_scale()
#
- planetary_coverage.math.sphere.sph_pixel_scale(e, ifov, d, r)[source]#
Compute pixel scale in spherical geometry.
Project both sides of the pixel iFOV on the sphere and measure its extend on the surface.
If the pixel extend above the limb, a
NaN
will be return.- Parameters
e (float, list or numpy.ndarray) – Local emission angle (in degrees).
ifov (float) – Pixel instantaneous field of view (in radians).
d (float, list or numpy.ndarray) – Distance from the observer to the target body center (in km).
r (float) – Target body radius (in km).
- Returns
Pixel scale on the surface (in km) and
NaN
if the pixel extend above the limb.- Return type
- Raises
ValueError – If the observer distance is smaller than the target radius.