asi_core.utils.geometry

Functions

to_radians(elevation, azimuth)

Converts elevation and azimuth angles from degrees to radians.

spherical_to_cartesian(azimuth, elevation, r)

Transform spherical to cartesian coordinates

cartesian_to_spherical(x, y, z)

Transform cartesian to spherical coordinates. See reverse function spherical_to_cartesian, for further convention.

is_circle_contour(contour[, aspect_ratio_tolerance, ...])

Determines if a contour is circular based on its aspect ratio and circularity.

Module Contents

asi_core.utils.geometry.to_radians(elevation, azimuth)

Converts elevation and azimuth angles from degrees to radians.

Parameters:
  • elevation – Elevation angle [º]

  • azimuth – Azimuth angle [º], over positive x-axis, rotating around z-axis

Returns:

(np.float64) Elevation and Azimuth angles in radians.

asi_core.utils.geometry.spherical_to_cartesian(azimuth, elevation, r)

Transform spherical to cartesian coordinates

Parameters:
  • azimuth – array of the azimuth angle [radians], over positive x-axis, rotating around z-axis

  • elevation – array of the elevation angle [radians]

  • r – array of the radius

Returns:

arrays of the cartesian coordinates x, y, z (same unit as radius)

asi_core.utils.geometry.cartesian_to_spherical(x, y, z)

Transform cartesian to spherical coordinates. See reverse function spherical_to_cartesian, for further convention.

Parameters:
  • x – cartesian coordinate x

  • y – cartesian coordinate y, same unit as x

  • z – cartesian coordinate z, same unit as x

Returns:

arrays of the azimuth angle [radians], elevation angle [radians], radius (same unit as x)

asi_core.utils.geometry.is_circle_contour(contour, aspect_ratio_tolerance=0.1, circularity_threshold=0.8)

Determines if a contour is circular based on its aspect ratio and circularity.

Parameters:
  • contour – (numpy.ndarray) The contour to analyze.

  • aspect_ratio_tolerance – (float, optional) The maximum difference between the aspect ratio of the contour’s bounding rectangle and 1. Default is 0.1.

  • circularity_threshold – (float, optional) The minimum circularity of the contour. Default is 0.7.

Returns:

  • is_circular, True if the contour is circular, False otherwise

  • aspcet_ratio, Aspect ratio of the contour

  • circularity, Circularity of the contour