pygeodesy.angles.Ang

Package pygeodesy :: Module angles :: Class Ang |
[frames] | no frames]

# Class Ang

      object --+
               |
    named._Named --+
                   |
                  Ang

An accurate representation of angles, as 3-tuple `(s, c, n)`.

This class represents an angle via its sine `s`, cosine `c` and the number of full turns `n`. The angle is then `atan2(s, c) + n * PI2`. This representation offers several advantages:

- cardinal directions (multiples of 90 degrees) are exactly represented (a benefit shared by representing angles as degrees)
- angles very close to any cardinal direction are accurately represented
- there's no loss of precision with large angles (outside the "normal" range [-180, +180])
- various operations, such as adding a multiple of 90 degrees to an angle are performed exactly.

Note: `n` is a `float`, this allows it to be NAN, INF or NINF.

Instance Methods
__init__(self, s_ang=0, c=None, n=0, normal=True, **unit_name) New Ang. |
__abs__(self) |
__add__(self, other) |
__bool__(self) |
__ceil__(self) |
__cmp__(self, other) |
__divmod__(self, other) |
__eq__(self, other) |
__float__(self) |
__floor__(self) |
__floordiv__(self, other) |
__ge__(self, other) |
__gt__(self, other) |
__hash__(self) hash(x) |
__iadd__(self, other) |
__ifloordiv__(self, other) |
__imatmul__(self, other) Not implemented. |
__imod__(self, other) |
__imul__(self, other) |
__int__(self) |
__invert__(self) |
__ipow__(self, other, *mod) |
__isub__(self, other) |
__itruediv__(self, other) |
__le__(self, other) |
__lt__(self, other) |
__matmul__(self, other) Not implemented. |
__mod__(self, other) |
__mul__(self, other) |
__ne__(self, other) |
__neg__(self) |
__pos__(self) |
__pow__(self, other, *mod) |
__radd__(self, other) |
__rdivmod__(self, other) |
__repr__(self) Default `repr(self)`. |
__rfloordiv__(self, other) |
__rmatmul__(self, other) Not implemented. |
__rmod__(self, other) |
__rmul__(self, other) |
__round__(self, *ndigits) |
__rpow__(self, other, *mod) |
__rsub__(self, other) |
__rtruediv__(self, other) |
__str__(self) Default `str(self)`. |
__sub__(self, other) |
__truediv__(self, other) |
__trunc__(self) |
__div__(self, other) |
__idiv__(self, other) |
__long__(self) |
__nonzero__(self) |
__rdiv__(self, other) |
base(self, *center) Return this `Angle`'s base, optionally centered. |
copy(self, **unit_name) Return a copy of this `Ang`. |
divmod(self, other) |
flipsign(self, mul=-1, **name) Copy this `Ang` with sign flipped. |
is_integer(self, *n) Is this `Ang`'s degrees `integer`? (`bool`). |
isnear0(self, eps0=staticmethod(pygeodesy.angles.Ang.EPS0)) Is this `Ang` near `0` within a tolerance? |
mod(self, mul=1.0, **unit_name) Return the reduced latitude `atan(mul * tan(this))` as an `Ang`. |
nearest(self, ind=0, **name) Return the closest cardinal direction (`Ang`). |
normalize(self, *n) Re-normalize this `Ang`, optionally replacing turns. |
pow(self, other, *mod) |
reflect(self, flips=False, flipc=False, swapsc=False) Reflect this `Ang` in various ways. |
round(self, *ndigits, **name) Return this `Ang`, optionally rounded to `ndigits` (`Ang`). |
shift(self, q=0, **unit_name) Shift this `Ang` by `q` quarter turns (`scalar`). |
signOf(self, *n) Determine this `Ang`'s sign, optionally replacing the turns. |
toDegrees(self, *n) Return this `Ang` as `Degrees`, optionally replacing the turns. |
toLambertian(self, **name) Return this `Ang` as Lambertian. |
toRadians(self, *n) Return this `Ang` as `Radians`, optionally replacing the turns. |
toRepr(self, *n, **prec_fmt) Return this `Ang` as `"<name>(<value>)"` with/out turns (`str`). |
toStr(self, *n, **prec_fmt) Return this `Ang` as `"<value>"` with/out turns (`str`). |
toTuple(self, **prec_fmt_sep) Return string `"(s, c, n)"` or tuple `('s', 'c', 'n')` if `sep is None`. |
toUnit(self, *n) Return this `Ang` as `self.unit`s, optionally replacing the turns. |
Inherited from `named._Named`: `__format__`, `attrs`, `classof`, `dup`, `methodname`, `rename`, `renamed`, `toStr2` Inherited from `object`: `__delattr__`, `__getattribute__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__sizeof__`, `__subclasshook__`

Static Methods
cardinal(q=0, **unit_name) A cardinal direction. |
EPS0(**unit_name) Get a tiny `Ang`. |
fromDegrees(deg, **unit_name) Get an `Ang` from degrees. |
fromLambertian(psi, **unit_name) Get an `Ang` from `lamberterian` radians. |
fromRadians(rad, **unit_name) Get an `Ang` from radians. |
fromScalar(ang, **unit_name) Get an `Ang` from `Degrees`, `Radians` or another `Ang`. |
N(**unit_name) Get North `Ang`. |
NAN(**unit_name) Get an invalid `Ang`. |

Properties
| c Get the cosine of this `Angle` (`float`).
| degrees Get this `Ang` in `degrees`.
| degrees0 Get this `Ang` in `degrees` ignoring the turns.
| lambertian Get this `Ang`'s Lambertian, `asinh(tan(radians))`.
| n Return the number of turns (`float`) or `0.0`.
| n0 Return the number of turns, treating `-180` as `180 - 1 turn` (`float`).
| ncardinal Get the nearest cardinal direction (`float_int`).
| quadrant Class `property` with a `.name` attribute.
| radians Get this `Ang` in `radians`.
| radians0 Get this `Ang` in `radians` ignoring the turns.
| s Get the sine of this `Ang` (`float`).
| sc2 Get the 2-tuple `(s, c)`.
| scn3 Get the 3-tuple `(s, c, n)`.
| scnu4 Get the 4-tuple `(s, c, n, unit)`.
| t Get the tangent of this `Ang` (`float`).
| unit Class `property` with a `.name` attribute.
Inherited from `named._Named`: `classname`, `classnaming`, `iteration`, `name`, `named`, `named2`, `named3`, `named4`, `sizeof`, `typename` Inherited from `object`: `__class__`

Method Details

### __init__ (self, s_ang=0, c=None, n=0, normal=True, **unit_name) (Constructor) |
New Ang. Arguments: `s_ang` - A previous Ang, `Degrees`, `Radians` if `c is None`, otherwise the sine component (`float`). `c` - The cosine component (`float`) iff `not None`. `n` - The number of PI2 turns (`float`). `normal` - If `True`, `s` and `c` are normalized, i.e. on the unit circle (`boo`). `unit_name` - Type `unit=`Radians or Degrees of scalar scalar values (Degrees or Radians). Overrides: object.__init__ Notes: Either `s` or `c` can be INF or NINF, but not both. By default, the point `(s, c)` is scaled to lie on the unit circle.

### __hash__ (self) (Hashing function) |
hash(x) Overrides: object.__hash__ (inherited documentation)

### __imatmul__ (self, other) |
Not implemented. Overrides: named._Named.__imatmul__ (inherited documentation)

### __matmul__ (self, other) |
Not implemented. Overrides: named._Named.__matmul__ (inherited documentation)

### __repr__ (self) (Representation operator) |
Default `repr(self)`. Overrides: object.__repr__ (inherited documentation)

### __rmatmul__ (self, other) |
Not implemented. Overrides: named._Named.__rmatmul__ (inherited documentation)

### __str__ (self) (Informal representation operator) |
Default `str(self)`. Overrides: object.__str__ (inherited documentation)

### cardinal (q=0, **unit_name) Static Method |
A cardinal direction. Arguments: `q` - The number of quarter turns (`scalar`). Returns: An `Ang` equivalent to `q` quarter turns. Note: `q` is truncated to an integer and signed `0` is distinguished. `Ang.NAN` is returned if `q` is not finite.

### copy (self, **unit_name) |
Return a copy of this `Ang`. Arguments: `deep` - If `True`, make a deep, otherwise a shallow copy (`bool`). `name` - Optional, non-empty `name=NN` (`str`). Returns: The copy (`This class`). Overrides: named._Named.copy

### EPS0 (**unit_name) Static Method |
Get a tiny `Ang`. Note: This allows angles extremely close to the cardinal directions to be generated. The `.round` method will flush this angle to `0`.

### mod (self, mul=1.0, **unit_name) |
Return the reduced latitude `atan(mul * tan(this))` as an `Ang`. Arguments: `mul` - Factor (`scalar`, positive). Note: The quadrant of the result tracks that of this `Ang` through multiples turns.

### nearest (self, ind=0, **name) |
Return the closest cardinal direction (`Ang`). Arguments: `ind` - An indicator, if `ind=0` the closest cardinal direction, otherwise, if `ind` is even, the closest even (N/S) cardinal direction or if `ind` is odd, the closest odd (E/W) cardinal direction.

### reflect (self, flips=False, flipc=False, swapsc=False) |
Reflect this `Ang` in various ways. Arguments: `flips` - Flip the sign of `s`. `flipc` - Flip the sign of `c`. `swapsc` - Swap `s` and `c`. Note: The operations are carried out in the order of the arguments.

### signOf (self, *n) |
Determine this `Ang`'s sign, optionally replacing the turns. Returns: The sign (`int`, -1, 0 or +1).

### toRepr (self, *n, **prec_fmt) |
Return this `Ang` as `"<name>(<value>)"` with/out turns (`str`). Overrides: named._Named.toRepr

### toStr (self, *n, **prec_fmt) |
Return this `Ang` as `"<value>"` with/out turns (`str`). Overrides: named._Named.toStr

Property Details

### c Get the cosine of this `Angle` (`float`). Get method: c(self) - Get the cosine of this `Angle` (`float`). Set method: _fset_error(inst, val) - Throws an `AttributeError`, always. Delete Method: _fdel(inst) - Zap the cached/memoized `property` value.

### degrees Get this `Ang` in `degrees`. Get method: degrees(self) - Get this `Ang` in `degrees`. Set method: _fset_error(inst, val) - Throws an `AttributeError`, always. Delete Method: _fdel(inst) - Zap the cached/memoized `property` value.

### degrees0 Get this `Ang` in `degrees` ignoring the turns. Get method: degrees0(self) - Get this `Ang` in `degrees` ignoring the turns. Set method: _fset_error(inst, val) - Throws an `AttributeError`, always. Delete Method: _fdel(inst) - Zap the cached/memoized `property` value.

### lambertian Get this `Ang`'s Lambertian, `asinh(tan(radians))`. Get method: lambertian(self) - Get this `Ang`'s Lambertian, `asinh(tan(radians))`. Set method: _fset_error(inst, val) - Throws an `AttributeError`, always. Delete Method: _fdel(inst) - Zap the cached/memoized `property` value.

### n Return the number of turns (`float`) or `0.0`. Get method: n(self) - Return the number of turns (`float`) or `0.0`. Set method: n(self, n)

### n0 Return the number of turns, treating `-180` as `180 - 1 turn` (`float`). Get method: n0(self) - Return the number of turns, treating `-180` as `180 - 1 turn` (`float`). Set method: n0(self, n)

### ncardinal Get the nearest cardinal direction (`float_int`). Get method: ncardinal(self) - Get the nearest cardinal direction (`float_int`). Set method: _fset_error(inst, val) - Throws an `AttributeError`, always. Delete Method: _fdel(inst) - Zap the cached/memoized `property` value. Note: This is the reverse of `cardinal`.

### quadrant Class `property` with a `.name` attribute. Get method: quadrant(self) Set method: quadrant(self, quadrant)

### radians Get this `Ang` in `radians`. Get method: radians(self) - Get this `Ang` in `radians`. Set method: _fset_error(inst, val) - Throws an `AttributeError`, always. Delete Method: _fdel(inst) - Zap the cached/memoized `property` value.

### radians0 Get this `Ang` in `radians` ignoring the turns. Get method: radians0(self) - Get this `Ang` in `radians` ignoring the turns. Set method: _fset_error(inst, val) - Throws an `AttributeError`, always. Delete Method: _fdel(inst) - Zap the cached/memoized `property` value.

### s Get the sine of this `Ang` (`float`). Get method: s(self) - Get the sine of this `Ang` (`float`). Set method: _fset_error(inst, val) - Throws an `AttributeError`, always. Delete Method: _fdel(inst) - Zap the cached/memoized `property` value.

### sc2 Get the 2-tuple `(s, c)`. Get method: sc2(self) - Get the 2-tuple `(s, c)`. Set method: _fset_error(inst, val) - Throws an `AttributeError`, always. Delete Method: _fdel(inst) - Zap the cached/memoized `property` value.

### scn3 Get the 3-tuple `(s, c, n)`. Get method: scn3(self) - Get the 3-tuple `(s, c, n)`. Set method: _fset_error(inst, val) - Throws an `AttributeError`, always. Delete Method: _fdel(inst) - Zap the cached/memoized `property` value.

### scnu4 Get the 4-tuple `(s, c, n, unit)`. Get method: scnu4(self) - Get the 4-tuple `(s, c, n, unit)`. Set method: _fset_error(inst, val) - Throws an `AttributeError`, always. Delete Method: _fdel(inst) - Zap the cached/memoized `property` value.

### t Get the tangent of this `Ang` (`float`). Get method: t(self) - Get the tangent of this `Ang` (`float`). Set method: _fset_error(inst, val) - Throws an `AttributeError`, always. Delete Method: _fdel(inst) - Zap the cached/memoized `property` value.

### unit Class `property` with a `.name` attribute. Get method: unit(self) Set method: unit(self, unit)