Geometry Utilities

Coordinate Conversion

ear.core.geom.cart(az, el, dist, axis=- 1)

Convert ADM-format polar positions to ADM-format Cartesian.

Parameters
  • az – Azimuths in degrees, angle measured anticlockwise from front.

  • el – Elevations in degrees, angle measured up from equator.

  • r – Radii.

  • axis – Index of the new axis in the result; see numpy.stack(). -1 (default) adds a new axis at the end.

Returns

Same shape as broadcasting az, el and r together, with a new axis at axis containing the X, Y and Z coordinates.

Return type

ndarray

Examples

>>> cart(0, 0, 1)
array([0., 1., 0.])
>>> cart(90, 0, 1).round(6)
array([-1.,  0.,  0.])
>>> cart(0, 90, 1).round(6)
array([0., 0., 1.])
>>> # inputs are broadcast together...
>>> cart([0, 90], 0, 1).round(6)
array([[ 0.,  1.,  0.],
       [-1.,  0.,  0.]])
>>> # ... along the given axis
>>> cart([0, 90], 0, 1, axis=0).round(6)
array([[ 0., -1.],
       [ 1.,  0.],
       [ 0.,  0.]])
ear.core.geom.azimuth(positions, axis=- 1)

Get the azimuth in degrees from ADM-format Cartesian positions.

Parameters
  • positions (array of float) – Cartesian positions, with X, Y and Z positions along axis axis.

  • axis (int) – Axis to find coordinates along. -1 (default) indicates the last axis.

Returns

Azimuths of the positions in degrees; has the same shape as

positions, with axis removed.

Return type

array

Raises

ValueError – If positions does not have the right length along axis.

Examples

>>> azimuth([0, 1, 0]).round(0).astype(int)
0
>>> azimuth([[1, 0, 0], [0, 1, 0]]).round(0).astype(int)
array([-90,   0])
>>> azimuth([[1, 0], [0, 1], [0, 0]], axis=0).round(0).astype(int)
array([-90,   0])
ear.core.geom.elevation(positions, axis=- 1)

Get the elevation in degrees from ADM-format Cartesian positions.

See azimuth().

ear.core.geom.distance(positions, axis=- 1)

Get the distance from ADM-format Cartesian positions.

See azimuth().

Angle Utilities

ear.core.geom.relative_angle(x, y)

Assuming y is clockwise from x, increment y by 360 until it’s not less than x.

Parameters
  • x (float) – start angle in degrees.

  • y (float) – end angle in degrees.

Returns

y shifted such that it represents the same angle but is greater than x.

Return type

float

ear.core.geom.inside_angle_range(x, start, end, tol=0.0)

Assuming end is clockwise from start, is the angle x inside [start,end] within some tolerance?

Parameters
  • x (float) – angle to test, in degrees

  • start (float) – start angle of range, in degrees

  • end (float) – end angle of range, in degrees

  • tol (float) – tolerance in degrees to check within

Returns

bool