pchandler.geometry.spherical.angle
Unit-aware angle scalar and array wrappers (radians / degrees / gon).
Classes
Represent a scalar (or, via |
|
Multi-dimensional array of angles, supporting indexing, iteration and unit conversion. |
|
Base class providing storage, unit conversion, comparison and arithmetic for angles. |
- class pchandler.geometry.spherical.angle.AngleBase
Bases:
objectBase class providing storage, unit conversion, comparison and arithmetic for angles.
Angles are always stored internally in radians; the
display_unitcontrols the unit used for string formatting anddisplay_value.- __init__(value, unit=AngleUnit.RAD)
Initialize an
AngleBase.Internally the angle is stored in radians;
unitspecifies the display unit (and the input unit ofvalue).- Parameters:
value (float | ArrayT) – Numeric value(s) interpreted in
unit.unit (AngleUnit, default=AngleUnit.RAD) – Unit in which
valueis supplied and in which the angle will be displayed.
- to(unit)
Convert the stored radians to
unitand return the numeric value.- Parameters:
unit (AngleUnit) – Target unit.
- Returns:
Numeric value(s) in
unit.- Return type:
Array_Float_T | float
- in_unit(unit)
Return a view of the angle with its display unit changed to
unit.- Parameters:
unit (AngleUnit) – Target display unit.
- Returns:
New instance sharing the underlying radian array.
- Return type:
- property display_unit: AngleUnit
Return the display unit currently set for the angle(s).
- Returns:
The current display unit.
- Return type:
AngleUnit
- property internal_value: float | Array_Float_T
Return the underlying stored angle value(s), always in radians.
- property display_value: GSEGUtils.base_types.Array_Float_T
Return the angle value(s) converted into the current display unit.
- property degrees: float | Array_Float_T
Return a copy of the angle value(s) in degrees.
- Returns:
Angle(s) in degrees.
- Return type:
float | Array_Float_T
- in_degrees()
Return a view of the angle(s) with display unit set to degrees.
- Returns:
New instance sharing the underlying radian array.
- Return type:
- property radians: float | Array_Float_T
Return a copy of the angle value(s) in radians.
- Returns:
Angle(s) in radians.
- Return type:
float | Array_Float_T
- in_radians()
Return a view of the angle(s) with display unit set to radians.
- Returns:
New instance sharing the underlying radian array.
- Return type:
- property gon: float | Array_Float_T
Return a copy of the angle value(s) in gradians (gon).
- Returns:
Angle(s) in gon.
- Return type:
float | Array_Float_T
- in_gon()
Return a view of the angle(s) with display unit set to gradians (gon).
- Returns:
New instance sharing the underlying radian array.
- Return type:
- min()
Return the minimum value of the angle(s) in radians.
- max()
Return the maximum value of the angle(s) in radians.
- class pchandler.geometry.spherical.angle.Angle
Bases:
AngleBaseRepresent a scalar (or, via
__new__dispatch, array) angle in any supported unit.Supports flexible construction from numbers, strings (
"45deg","0.5 rad","200.4gon"), and array-like inputs. Array inputs are upcast toAngleArray.- Parameters:
value (float) – The numerical representation of the angle.
unit (AngleUnit) – The unit of the angle, such as radians or degrees.
- static __new__(cls, value, unit=AngleUnit.RAD)
Return a new
AngleorAngleArraybased on the input shape.- Parameters:
- Returns:
An instance of either
AngleorAngleArraydepending on the dimension of the input value.- Return type:
Angle or AngleArray
- classmethod parse(value)
Build an
Angle/AngleArrayfrom a variety of input formats.Supported formats include:
Angle | AngleArray
(value, unit) tuple
single string
"45deg","0.5 rad","200.4gon", etc.numpy scalar
int | float
numpy array
list | tuple of numbers
- Parameters:
value (Any) – Input value to parse into an angle.
- Returns:
The parsed angle.
- Return type:
- Raises:
ValueError – If
valuecannot be parsed as an angle.
- class pchandler.geometry.spherical.angle.AngleArray
Bases:
AngleBaseMulti-dimensional array of angles, supporting indexing, iteration and unit conversion.
- Parameters:
arr (ArrayT) – The array of angle values.
unit (AngleUnit, default=AngleUnit.RAD) – The unit in which
arris supplied (also the initial display unit).
- static __new__(cls, arr, unit=AngleUnit.RAD)
Return a new
AngleArraycarryingarr(a copy as float64).