pylag.math module

Module implementing several basic mathematical functions

Note

math is implemented in Cython. Only a small portion of the API is exposed in Python with accompanying documentation.

pylag.math.angle_between_two_unit_vectors_wrapper(vector[DTYPE_FLOAT_t] a, vector[DTYPE_FLOAT_t] b)
pylag.math.area_of_a_spherical_triangle_wrapper(vector[DTYPE_FLOAT_t] x1, vector[DTYPE_FLOAT_t] x2, vector[DTYPE_FLOAT_t] x3, DTYPE_FLOAT_t r)
pylag.math.area_of_a_triangle_wrapper(vector[DTYPE_FLOAT_t] x1, vector[DTYPE_FLOAT_t] x2, vector[DTYPE_FLOAT_t] x3)
pylag.math.cartesian_to_geographic_coords_python(x, y, z)

Convert cartesian to geographic coordinates

(x, y, z) should be unit vectors.

Parameters
  • (x (float) – (x,y,z) coordinates

  • y (float) – (x,y,z) coordinates

  • z) (float) – (x,y,z) coordinates

Returns

lon, lat – Longitude and latitude in radians

Return type

float

pylag.math.cartesian_to_geographic_coords_wrapper(vector[DTYPE_FLOAT_t] coords_cart)
pylag.math.cartesian_to_sigma_coords(DTYPE_FLOAT_t z, DTYPE_FLOAT_t h, DTYPE_FLOAT_t zeta) DTYPE_FLOAT_t
pylag.math.det_second_order_wrapper(vector[DTYPE_FLOAT_t] p1, vector[DTYPE_FLOAT_t] p2)
pylag.math.det_third_order_wrapper(vector[DTYPE_FLOAT_t] p1, vector[DTYPE_FLOAT_t] p2, vector[DTYPE_FLOAT_t] p3)
pylag.math.euclidian_norm_wrapper(vector[DTYPE_FLOAT_t] p1)
pylag.math.geographic_to_cartesian_coords_python(lon_rad, lat_rad)

Convert geographic to cartesian coordinates on a unit sphere

Pure python implementation of the conversion from geographic to cartesian coordinates which acts on numpy arrays.

Parameters
  • lon_rad (NumPy 1D array) – Longitude radians

  • lat_rad (NumPy 1D array) – Latitude in radians

Returns

x, y, z – Cartesian coordinates.

Return type

NumPy 1D arrays

pylag.math.geographic_to_cartesian_coords_wrapper(DTYPE_FLOAT_t lon_rad, DTYPE_FLOAT_t lat_rad, DTYPE_FLOAT_t r)
pylag.math.get_intersection_point_in_geographic_coordinates_wrapper(vector[DTYPE_FLOAT_t] x1, vector[DTYPE_FLOAT_t] x2, vector[DTYPE_FLOAT_t] x3, vector[DTYPE_FLOAT_t] x4, in_degrees=True)
pylag.math.get_intersection_point_wrapper(vector[DTYPE_FLOAT_t] x1, vector[DTYPE_FLOAT_t] x2, vector[DTYPE_FLOAT_t] x3, vector[DTYPE_FLOAT_t] x4)
pylag.math.great_circle_arc_segments_intersect_wrapper(vector[DTYPE_FLOAT_t] x1, vector[DTYPE_FLOAT_t] x2, vector[DTYPE_FLOAT_t] x3, vector[DTYPE_FLOAT_t] x4)
pylag.math.haversine(DTYPE_FLOAT_t lon1_rad, DTYPE_FLOAT_t lat1_rad, DTYPE_FLOAT_t lon2_rad, DTYPE_FLOAT_t lat2_rad) DTYPE_FLOAT_t

Calculate the great circle distance between two points on the unit sphere

Parameters
  • lon1_rad (float) – Longitude and latitude of point 1 in radians

  • lat1_rad (float) – Longitude and latitude of point 1 in radians

  • lon2_rad (float) – Longitude and latitude of point 2 in radians

  • lat2_rad (float) – Longitude and latitude of point 2 in radians

Returns

The distance in meters

Return type

float

pylag.math.inner_product_three_wrapper(vector[DTYPE_FLOAT_t] p1, vector[DTYPE_FLOAT_t] p2)
pylag.math.inner_product_two_wrapper(vector[DTYPE_FLOAT_t] p1, vector[DTYPE_FLOAT_t] p2)
pylag.math.rotate_axes_wrapper(vector[DTYPE_FLOAT_t] p, DTYPE_FLOAT_t lon_rad, DTYPE_FLOAT_t lat_rad)
pylag.math.rotate_x_wrapper(vector[DTYPE_FLOAT_t] p, DTYPE_FLOAT_t angle)
pylag.math.rotate_y_wrapper(vector[DTYPE_FLOAT_t] p, DTYPE_FLOAT_t angle)
pylag.math.rotate_z_wrapper(vector[DTYPE_FLOAT_t] p, DTYPE_FLOAT_t angle)
pylag.math.sigma_to_cartesian_coords(DTYPE_FLOAT_t sigma, DTYPE_FLOAT_t h, DTYPE_FLOAT_t zeta) DTYPE_FLOAT_t
pylag.math.unit_vector_wrapper(vector[DTYPE_FLOAT_t] a)
pylag.math.vector_product_wrapper(vector[DTYPE_FLOAT_t] a, vector[DTYPE_FLOAT_t] b)