astrix.utils module

Utility functions for Astrix.

Should not be imported to core type modules to avoid circular dependencies.

defeature_path(path, tol=50.0)[source]

Defeature a path by removing points that are within tol meters of a straight line between their neighbors. The first and last points are always kept. Useful for plotting.

Parameters:
  • path (Path) – Path The path to defeature.

  • tol (float) – float The tolerance in meters. Points that are within this distance of a straight line between their neighbors will be removed. Default is 50 meters.

Return type:

Path

Returns:

Path

A new path with fewer points.

dist(a, b, backend=None)[source]

Calculate the Euclidean distance between two points.

Return type:

Any

Parameters:
get_ned_rotation(loc, backend=None)[source]

Calculate the rotation matrix from ECEF to NED frame at the given location.

Parameters:
  • loc (Location) – Location The location to calculate the NED rotation matrix for.

  • backend (str | Any | None) – BackendArg The backend to use. If None, uses the backend of the location.

Return type:

Rotation

Returns:

Rotation

The rotation matrix from ECEF to NED frame at the given location.

ground_path(path, alt=0.0)[source]

Return a new path with all points at the specified altitude (default 0 m).

Parameters:
  • path (Path) – Path The path to ground.

  • alt (float) – float The altitude in meters. Default is 0 m.

Return type:

Path

Returns:

Path

A new path with all points at the specified altitude.

path_to_az_el_rate(path, time, frame, backend=None)[source]

Project the velocity vectors of a path to azimuth and elevation components

Return type:

Any

Parameters:
  • path (Path)

  • time (Time)

  • frame (Frame)

  • backend (str | Any | None)

point_from_heading(start, head, dist, time_new=Time invariant (n=1), method='haversine')[source]

Calculate a new point given a start point, heading (degrees) and distance (meters). If point has len > 1, uses the last point.

Note: Applicable for NumPy backend only.

Return type:

Point

Parameters:
  • start (Point)

  • head (float)

  • dist (float)

  • time_new (Time)

  • method (str)

solve_wahba(v, w, weights=None)[source]

Calculate the rotation matrix R which transforms vectors w to v. It is posed as Wahba’s problem https://en.wikipedia.org/wiki/Wahba%27s_problem

Parameters:
  • v (Any) – vectors in the first coordiante frame

  • w (Any) – vectors in the second coordinate frame

  • weights (Any | None) – weights associated with each vector. Otherwise assumed even weights (NumPy only)

Return type:

tuple[Any, Any]

Returns:

  • R (3x3 numpy array) – The rotation matrix such that w ~ Rv

  • delta_angle_deg ((n,) numpy array) – Angle differences between rotated w and v, in degrees, as a quality metric

Note these functions are very important for real-time evaluation. They need robust functional testing and good coding practices.