AngularPosition

class AngularPosition(value: float | int, unit: str)

Bases: UnitBase

AngularPosition object.

Attributes

unitstr

Symbol of the unit of measurement for angular position.

valuefloat or int

Angular position numerical value.

Methods

to()

It converts actual value to a new value computed using target_unit as the reference unit of measurement.

sin()

It computes the sine of the angular position at a given frequency.

cos()

It computes the cosine of the angular position at a given frequency.

tan()

It computes the tangent of the angular position at a given frequency.

cos(frequency: float | int | None = 0.15915494309189535) float

It computes the cosine of the angular position at a given frequency.

Parameters

frequencyfloat or int, optional

Frequency to multiply by before computing the cosine. Default is \(\frac{1}{2 \pi}\).

Returns

float

Computed cosine of the angular position.

sin(frequency: float | int | None = 0.15915494309189535) float

It computes the sine of the angular position at a given frequency.

Parameters

frequencyfloat or int, optional

Frequency to multiply by before computing the sine. Default is \(\frac{1}{2 \pi}\).

Returns

float

Computed sine of the angular position.

tan(frequency: float | int | None = 0.15915494309189535) float

It computes the tangent of the angular position at a given frequency.

Parameters

frequencyfloat or int, optional

Frequency to multiply by before computing the tangent. Default is \(\frac{1}{2 \pi}\).

Returns

float

Computed tangent of the angular position.

to(target_unit: str, inplace: bool = False) AngularPosition

It converts actual value to a new value computed using target_unit as the reference unit of measurement.

If inplace is True, it overrides actual value and unit, otherwise it returns a new instance with the converted value and the target_unit as unit.

Parameters

target_unitstr

Target unit to which convert the current value.

inplacebool, optional

Whether to override the current instance value. Default is False, so it does not override the current value.

Returns

AngularPosition

Converted angular position.

Raises

TypeError
  • If target_unit is not a str,

  • if inplace is not a bool.

KeyError

If the target_unit is not among available ones.

Examples

AngularPosition instantiation.

>>> from gearpy.units import AngularPosition
>>> p = AngularPosition(180, 'deg')
>>> p
180 deg

Conversion from degree to radian with inplace=False by default, so it does not override the current value.

>>> p.to('rad')
3.141592653589793 rad
>>> p
180 deg

Conversion from degree to minute of arc with inplace=True, in order to override the current value.

>>> p.to('arcmin', inplace=True)
10800.0 arcmin
>>> p
10800.0 arcmin
property unit: str

Symbol of the unit of measurement for angular position. It must be a str. Available units are:

  • 'rad' for radian,

  • 'deg' for degree,

  • 'arcmin' for minute of arc,

  • 'arcsec' for second of arc,

  • 'rot' for rotation.

Returns

str

Symbol of the unit of measurement for angular position.

Raises

TypeError

If unit is not a str.

KeyError

If the unit is not among available ones.

property value: float | int

Angular position numerical value. The relative unit is expressed by the unit property.

Returns

float or int

Angular position numerical value.

Raises

TypeError

If value is not a float or an int.