more-transformations 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- more_transformations/__init__.py +94 -0
- more_transformations/_shapes.py +184 -0
- more_transformations/_triads.py +35 -0
- more_transformations/_units.py +29 -0
- more_transformations/_version.py +24 -0
- more_transformations/angles.py +764 -0
- more_transformations/attitude_determination.py +504 -0
- more_transformations/casadi/__init__.py +65 -0
- more_transformations/casadi/angles.py +552 -0
- more_transformations/casadi/attitude_determination.py +229 -0
- more_transformations/casadi/ecef.py +778 -0
- more_transformations/casadi/euler.py +768 -0
- more_transformations/casadi/flat_earth.py +239 -0
- more_transformations/casadi/frames.py +806 -0
- more_transformations/casadi/geodesic.py +287 -0
- more_transformations/casadi/linalg.py +143 -0
- more_transformations/casadi/parameters.py +624 -0
- more_transformations/casadi/pose.py +401 -0
- more_transformations/casadi/quaternion.py +1198 -0
- more_transformations/casadi/rigid_body.py +174 -0
- more_transformations/casadi/rotations.py +459 -0
- more_transformations/casadi/utils.py +353 -0
- more_transformations/casadi/utm.py +269 -0
- more_transformations/constants.py +70 -0
- more_transformations/data/README +65 -0
- more_transformations/data/WMM2010.COF +93 -0
- more_transformations/data/WMM2015v2.COF +93 -0
- more_transformations/data/WMM2020.COF +93 -0
- more_transformations/data/WMM2025.COF +93 -0
- more_transformations/data/WMMHR2025.COF +9047 -0
- more_transformations/data/egm96_15.npz +0 -0
- more_transformations/ecef.py +883 -0
- more_transformations/euler.py +903 -0
- more_transformations/flat_earth.py +243 -0
- more_transformations/frames.py +1015 -0
- more_transformations/geodesic.py +963 -0
- more_transformations/geoid.py +166 -0
- more_transformations/kernels/__init__.py +102 -0
- more_transformations/kernels/_compile_ready.py +36 -0
- more_transformations/kernels/_numba.py +23 -0
- more_transformations/kernels/angles.py +139 -0
- more_transformations/kernels/ecef.py +70 -0
- more_transformations/kernels/euler.py +320 -0
- more_transformations/kernels/rotations.py +131 -0
- more_transformations/linalg.py +359 -0
- more_transformations/magnetic.py +451 -0
- more_transformations/pose.py +521 -0
- more_transformations/py.typed +0 -0
- more_transformations/quaternion.py +1443 -0
- more_transformations/rigid_body.py +207 -0
- more_transformations/rotations.py +517 -0
- more_transformations/utm.py +350 -0
- more_transformations-1.0.0.dist-info/METADATA +370 -0
- more_transformations-1.0.0.dist-info/RECORD +58 -0
- more_transformations-1.0.0.dist-info/WHEEL +5 -0
- more_transformations-1.0.0.dist-info/entry_points.txt +2 -0
- more_transformations-1.0.0.dist-info/licenses/LICENSE +201 -0
- more_transformations-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"""
|
|
2
|
+
more_transformations
|
|
3
|
+
====================
|
|
4
|
+
|
|
5
|
+
Coordinate frame and attitude transformations for marine robotics, following
|
|
6
|
+
the conventions of Fossen, T. I. (2011), *Handbook of Marine Craft
|
|
7
|
+
Hydrodynamics and Motion Control*, Wiley, chapter 2: NED and BODY frames, ZYX
|
|
8
|
+
Euler angles and scalar-first unit quaternions. Every function cites the
|
|
9
|
+
sources of its equations in its References section.
|
|
10
|
+
|
|
11
|
+
Modules
|
|
12
|
+
-------
|
|
13
|
+
- angles : wrapping, unwrapping, circular mean, course and bearing
|
|
14
|
+
- rotations : elementary rotations, skew matrix, 6 x 6 lever-arm matrix
|
|
15
|
+
- pose : rigid poses (p, R): compose, invert, interpolate, exp, log, matrix form, adjoint
|
|
16
|
+
- euler : ZYX Euler angles, BODY and NED
|
|
17
|
+
- quaternion : unit quaternions (w, x, y, z), BODY and NED
|
|
18
|
+
- ecef : exact WGS-84 geodesy, geodetic, ECEF and local NED/ENU
|
|
19
|
+
- flat_earth : flat-Earth approximation with the signatures of ``ecef``
|
|
20
|
+
- frames : NED/FRD and ENU/FLU (ROS REP-103)
|
|
21
|
+
- rigid_body : lever-arm transfer of velocity, acceleration, twist and wrench
|
|
22
|
+
- attitude_determination: QUEST, pose from markers, static attitude from IMU
|
|
23
|
+
- geodesic : great-circle and WGS-84 distance, bearing, destination, DMS
|
|
24
|
+
- utm : UTM projection
|
|
25
|
+
- magnetic : WMM and WMMHR magnetic declination
|
|
26
|
+
- geoid : EGM96 geoid undulation, h = H + N
|
|
27
|
+
- linalg : symmetry, positive definiteness and inversion of matrices
|
|
28
|
+
- constants : WGS-84, gravity, UTM and Earth-radius constants
|
|
29
|
+
|
|
30
|
+
Each module lists its functions in ``__all__`` and has a namespace class of
|
|
31
|
+
the same name in CapWords (``euler`` and ``Euler``) that holds the same
|
|
32
|
+
functions as static methods.
|
|
33
|
+
|
|
34
|
+
Angles are in radians and quaternions are scalar-first ``(w, x, y, z)``, except
|
|
35
|
+
in the geodetic modules (``ecef``, ``flat_earth``, ``geodesic``, ``utm``,
|
|
36
|
+
``magnetic`` and ``geoid``), where ``unit="deg"`` is the default for every angle, bearings and
|
|
37
|
+
the declination included. A point comes before its reference.
|
|
38
|
+
|
|
39
|
+
``numpy``, ``casadi`` and ``numba`` are required dependencies; ``casadi`` and
|
|
40
|
+
``numba`` are loaded only when the code that needs them is imported, not by
|
|
41
|
+
``import more_transformations``. The WGS-84 geodesics of ``geodesic`` and the
|
|
42
|
+
World Magnetic Model of ``magnetic`` are computed in the package, and the EGM96 grid of ``geoid`` is package data read on first use.
|
|
43
|
+
|
|
44
|
+
The same functions in CasADi form live in ``more_transformations.casadi`` (not
|
|
45
|
+
imported here). Compile-ready plain forms (floats in, fixed-size tuples out,
|
|
46
|
+
accepted by ``numba.njit``) of the ZYX rotation, the
|
|
47
|
+
Euler-rate map and its inverse, the angle wrap, the planar course rotation and
|
|
48
|
+
the Earth's rotation rate in NED live in ``more_transformations.kernels``; the
|
|
49
|
+
numpy functions are built from them.
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
try: # written by setuptools-scm at build/install time from the git tag
|
|
53
|
+
from more_transformations._version import __version__
|
|
54
|
+
except ImportError: # a source tree that was never built or installed
|
|
55
|
+
__version__ = "0+unknown"
|
|
56
|
+
|
|
57
|
+
from more_transformations import (
|
|
58
|
+
angles,
|
|
59
|
+
attitude_determination,
|
|
60
|
+
constants,
|
|
61
|
+
ecef,
|
|
62
|
+
euler,
|
|
63
|
+
flat_earth,
|
|
64
|
+
frames,
|
|
65
|
+
geodesic,
|
|
66
|
+
geoid,
|
|
67
|
+
linalg,
|
|
68
|
+
magnetic,
|
|
69
|
+
pose,
|
|
70
|
+
quaternion,
|
|
71
|
+
rigid_body,
|
|
72
|
+
rotations,
|
|
73
|
+
utm,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
__all__ = [
|
|
77
|
+
"angles",
|
|
78
|
+
"attitude_determination",
|
|
79
|
+
"constants",
|
|
80
|
+
"ecef",
|
|
81
|
+
"euler",
|
|
82
|
+
"flat_earth",
|
|
83
|
+
"frames",
|
|
84
|
+
"geodesic",
|
|
85
|
+
"geoid",
|
|
86
|
+
"linalg",
|
|
87
|
+
"magnetic",
|
|
88
|
+
"pose",
|
|
89
|
+
"quaternion",
|
|
90
|
+
"rigid_body",
|
|
91
|
+
"rotations",
|
|
92
|
+
"utm",
|
|
93
|
+
"__version__",
|
|
94
|
+
]
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"""Shape checks of the public functions (private)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import math
|
|
6
|
+
from typing import TYPE_CHECKING, Any
|
|
7
|
+
|
|
8
|
+
import numpy as np
|
|
9
|
+
from numpy.typing import ArrayLike, NDArray
|
|
10
|
+
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
from collections.abc import Callable
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def as_float(x: Any) -> NDArray[np.float64]:
|
|
16
|
+
"""``x`` as a float array. ``TypeError`` for a value that is not a real number or an array of real numbers
|
|
17
|
+
(``None``, a string, a complex number, a symbolic or other object), ``ValueError`` for a ragged sequence."""
|
|
18
|
+
a = np.asarray(x)
|
|
19
|
+
kind = a.dtype.kind
|
|
20
|
+
if kind == "O":
|
|
21
|
+
if not all(isinstance(e, (int, float, np.integer, np.floating, np.bool_)) for e in a.flat):
|
|
22
|
+
raise TypeError(f"expected real numbers, got {type(x).__name__}")
|
|
23
|
+
elif kind not in "biuf":
|
|
24
|
+
raise TypeError(f"expected real numbers, got {type(x).__name__} of dtype {a.dtype}")
|
|
25
|
+
return a.astype(float, copy=False)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def real_scalar(x: Any, name: str = "x") -> float:
|
|
29
|
+
"""``x`` as a float: a single real number. ``TypeError`` for a value of another type, ``ValueError`` for an array of
|
|
30
|
+
other than one element."""
|
|
31
|
+
a = as_float(x)
|
|
32
|
+
if a.size != 1:
|
|
33
|
+
raise ValueError(f"{name} must be a scalar, got shape {a.shape}")
|
|
34
|
+
return float(a.reshape(()))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def finite_scalar(x: Any, name: str = "x") -> float:
|
|
38
|
+
"""``x`` as a finite float: a single real number that is neither infinite nor NaN. ``TypeError`` for a value of
|
|
39
|
+
another type, ``ValueError`` for an array of other than one element or a non-finite number."""
|
|
40
|
+
v = real_scalar(x, name)
|
|
41
|
+
if not math.isfinite(v):
|
|
42
|
+
raise ValueError(f"{name} must be finite, got {v}")
|
|
43
|
+
return v
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def tolerance(x: Any, name: str = "tol") -> float:
|
|
47
|
+
"""``x`` as a tolerance: a finite real number that is at least 0. ``TypeError`` for a value of another type,
|
|
48
|
+
``ValueError`` for a non-finite or negative number."""
|
|
49
|
+
v = finite_scalar(x, name)
|
|
50
|
+
if v < 0.0:
|
|
51
|
+
raise ValueError(f"{name} must be >= 0, got {v}")
|
|
52
|
+
return v
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def text(x: Any, name: str = "x") -> str:
|
|
56
|
+
"""``x`` itself if it is a ``str``; ``TypeError`` otherwise."""
|
|
57
|
+
if not isinstance(x, str):
|
|
58
|
+
raise TypeError(f"{name} must be a str, got {type(x).__name__}")
|
|
59
|
+
return x
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def flag(x: Any, name: str = "x") -> bool:
|
|
63
|
+
"""``x`` itself if it is a ``bool``; ``TypeError`` otherwise."""
|
|
64
|
+
if not isinstance(x, (bool, np.bool_)):
|
|
65
|
+
raise TypeError(f"{name} must be a bool, got {type(x).__name__}")
|
|
66
|
+
return bool(x)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def integer(x: Any, name: str = "x") -> int:
|
|
70
|
+
"""``x`` as an ``int`` if it is an integer (not a ``bool``); ``TypeError`` for another type."""
|
|
71
|
+
if isinstance(x, (bool, np.bool_)) or not isinstance(x, (int, np.integer)):
|
|
72
|
+
raise TypeError(f"{name} must be an integer, got {type(x).__name__}")
|
|
73
|
+
return int(x)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def positive_integer(x: Any, name: str = "x") -> int:
|
|
77
|
+
"""``x`` as an ``int`` of at least 1; ``TypeError`` for a value that is not an integer, ``ValueError`` below 1."""
|
|
78
|
+
v = integer(x, name)
|
|
79
|
+
if v < 1:
|
|
80
|
+
raise ValueError(f"{name} must be a positive integer, got {v}")
|
|
81
|
+
return v
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def non_negative_integer(x: Any, name: str = "x") -> int:
|
|
85
|
+
"""``x`` as an ``int`` of at least 0; ``TypeError`` for a value that is not an integer, ``ValueError`` below 0."""
|
|
86
|
+
v = integer(x, name)
|
|
87
|
+
if v < 0:
|
|
88
|
+
raise ValueError(f"{name} must be a non-negative integer, got {v}")
|
|
89
|
+
return v
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def vector(x: ArrayLike, n: int | tuple[int, ...], name: str = "x") -> NDArray[np.float64]:
|
|
93
|
+
"""``x`` as a float array of shape ``(n,)``, or of one of the lengths in the tuple ``n``.
|
|
94
|
+
|
|
95
|
+
``TypeError`` for a value that is not a number or a sequence of numbers, ``ValueError`` for any other shape.
|
|
96
|
+
"""
|
|
97
|
+
a = as_float(x)
|
|
98
|
+
sizes = n if isinstance(n, tuple) else (n,)
|
|
99
|
+
if a.ndim != 1 or a.shape[0] not in sizes:
|
|
100
|
+
wanted = " or ".join(map(str, sizes))
|
|
101
|
+
raise ValueError(f"{name} must have {wanted} elements, got shape {a.shape}")
|
|
102
|
+
return a
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def planar_batch(x: ArrayLike, name: str = "x") -> NDArray[np.float64]:
|
|
106
|
+
"""``x`` as a float array whose last axis has at least two components (north and east, or east and north)."""
|
|
107
|
+
a = as_float(x)
|
|
108
|
+
if a.ndim < 1 or a.shape[-1] < 2:
|
|
109
|
+
raise ValueError(f"{name} must have at least 2 components on its last axis, got shape {a.shape}")
|
|
110
|
+
return a
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def vector_batch(x: ArrayLike, n: int | tuple[int, ...], name: str = "x") -> NDArray[np.float64]:
|
|
114
|
+
"""``x`` as a float array whose last axis has ``n`` components (``(n,)`` or ``(N, n)``).
|
|
115
|
+
|
|
116
|
+
``TypeError`` for a value that is not a number or a sequence of numbers, ``ValueError`` for any other shape.
|
|
117
|
+
"""
|
|
118
|
+
a = as_float(x)
|
|
119
|
+
sizes = n if isinstance(n, tuple) else (n,)
|
|
120
|
+
if a.ndim < 1 or a.shape[-1] not in sizes:
|
|
121
|
+
wanted = " or ".join(map(str, sizes))
|
|
122
|
+
raise ValueError(f"{name} must have {wanted} elements, got shape {a.shape}")
|
|
123
|
+
return a
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def matrix_batch(M: ArrayLike, rows: int, cols: int, name: str = "R") -> NDArray[np.float64]:
|
|
127
|
+
"""``M`` as a float array whose last two axes are ``rows`` x ``cols`` (one matrix or a stack)."""
|
|
128
|
+
a = as_float(M)
|
|
129
|
+
if a.ndim < 2 or a.shape[-2:] != (rows, cols):
|
|
130
|
+
raise ValueError(f"{name} must be a {rows}x{cols} matrix, got {a.shape}")
|
|
131
|
+
return a
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def broadcast_batch(*items: tuple[NDArray[np.float64], int]) -> tuple[NDArray[np.float64], ...]:
|
|
135
|
+
"""Broadcast arrays to their common batch shape. Each item is ``(array, core_ndim)``: the trailing ``core_ndim``
|
|
136
|
+
axes of the array belong to one sample (1 for a vector, 2 for a matrix, 0 for a scalar), all axes before them are
|
|
137
|
+
batch axes. An array that already has the common batch shape is returned as it is, any other is expanded to a
|
|
138
|
+
writable copy. ``ValueError`` if the batch shapes cannot be broadcast together."""
|
|
139
|
+
batch = np.broadcast_shapes(*(a.shape[: a.ndim - c] for a, c in items))
|
|
140
|
+
out = []
|
|
141
|
+
for a, c in items:
|
|
142
|
+
core = a.shape[a.ndim - c :]
|
|
143
|
+
out.append(a if a.shape[: a.ndim - c] == batch else np.array(np.broadcast_to(a, batch + core)))
|
|
144
|
+
return tuple(out)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def mat_vec(M: NDArray[np.float64], v: NDArray[np.float64]) -> NDArray[np.float64]:
|
|
148
|
+
"""``M v`` for one matrix and vector, or for stacks of them (broadcast over the leading axes)."""
|
|
149
|
+
return np.asarray(np.matmul(M, v[..., None])[..., 0])
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def map_scalars(
|
|
153
|
+
fn: Callable[..., tuple[Any, ...]], *args: ArrayLike, n_out: int, dtypes: tuple[Any, ...] | None = None
|
|
154
|
+
) -> tuple[Any, ...]:
|
|
155
|
+
"""Apply a scalar function, which returns ``n_out`` values, to every element of the broadcast arguments.
|
|
156
|
+
|
|
157
|
+
Integer and boolean arguments are passed on as they are, all others as floats. Scalar arguments give a tuple of
|
|
158
|
+
Python numbers; arrays of one shape ``s`` give a tuple of arrays of shape ``s`` (float unless ``dtypes`` says
|
|
159
|
+
otherwise). The scalar function is the only implementation, so a batch equals its stacked single results bit
|
|
160
|
+
for bit.
|
|
161
|
+
"""
|
|
162
|
+
converted = []
|
|
163
|
+
for a in args:
|
|
164
|
+
arr = np.asarray(a)
|
|
165
|
+
converted.append(arr if arr.dtype.kind in "iub" else as_float(arr))
|
|
166
|
+
arrays = np.broadcast_arrays(*converted)
|
|
167
|
+
shape = arrays[0].shape
|
|
168
|
+
if shape == ():
|
|
169
|
+
return tuple(fn(*(a.item() for a in arrays)))
|
|
170
|
+
kinds = dtypes if dtypes is not None else (float,) * n_out
|
|
171
|
+
out = [np.empty(shape, dtype=k) for k in kinds]
|
|
172
|
+
for idx in np.ndindex(*shape):
|
|
173
|
+
for k, value in enumerate(fn(*(a[idx].item() for a in arrays))):
|
|
174
|
+
out[k][idx] = value
|
|
175
|
+
return tuple(out)
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def check_wrap(wrap: str) -> str:
|
|
179
|
+
"""``wrap`` itself if it is ``"signed"`` or ``"positive"`` (``ValueError`` otherwise, ``TypeError`` for a non-string)."""
|
|
180
|
+
if not isinstance(wrap, str):
|
|
181
|
+
raise TypeError(f"wrap must be 'signed' or 'positive', got {wrap!r}")
|
|
182
|
+
if wrap not in ("signed", "positive"):
|
|
183
|
+
raise ValueError(f"wrap must be 'signed' or 'positive', got {wrap!r}")
|
|
184
|
+
return wrap
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""Axis letters of the world and body triads and their check; plain Python, shared by both layers."""
|
|
2
|
+
|
|
3
|
+
# Unit vectors of each axis letter: world letters in NED coordinates, body letters in FRD
|
|
4
|
+
# coordinates.
|
|
5
|
+
_WORLD_AXES = {
|
|
6
|
+
"N": (1, 0, 0), "S": (-1, 0, 0), "E": (0, 1, 0), "W": (0, -1, 0), "D": (0, 0, 1), "U": (0, 0, -1),
|
|
7
|
+
}
|
|
8
|
+
_BODY_AXES = {
|
|
9
|
+
"F": (1, 0, 0), "B": (-1, 0, 0), "R": (0, 1, 0), "L": (0, -1, 0), "D": (0, 0, 1), "U": (0, 0, -1),
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _triad_rows(
|
|
14
|
+
name: str, axes: dict[str, tuple[int, int, int]], what: str
|
|
15
|
+
) -> tuple[tuple[int, int, int], ...]:
|
|
16
|
+
"""Rows of the axis matrix of a triad as tuples of ints; the check shared with the CasADi layer."""
|
|
17
|
+
if not isinstance(name, str):
|
|
18
|
+
raise TypeError(f"{what} must be a string of three letters, got {type(name).__name__}")
|
|
19
|
+
text = name.strip().upper()
|
|
20
|
+
letters = "".join(axes)
|
|
21
|
+
if len(text) != 3 or any(c not in axes for c in text):
|
|
22
|
+
raise ValueError(f"{what} must be three letters from {letters} (any case), got {name!r}")
|
|
23
|
+
rows = tuple(axes[c] for c in text)
|
|
24
|
+
if len({tuple(abs(v) for v in r) for r in rows}) < 3:
|
|
25
|
+
raise ValueError(f"{what} {text!r} uses one axis line twice")
|
|
26
|
+
(a, b, c), (d, e, f), (g, h, i) = rows
|
|
27
|
+
if a * (e * i - f * h) - b * (d * i - f * g) + c * (d * h - e * g) < 0:
|
|
28
|
+
raise ValueError(f"{what} {text!r} is left-handed (determinant -1)")
|
|
29
|
+
return rows
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _key(name: str) -> str:
|
|
33
|
+
if not isinstance(name, str):
|
|
34
|
+
raise TypeError(f"a frame name must be a string of three letters, got {type(name).__name__}")
|
|
35
|
+
return name.strip().upper()
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Angle-unit helpers shared by the geodetic modules (private)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import numpy as np
|
|
8
|
+
from numpy.typing import ArrayLike, NDArray
|
|
9
|
+
|
|
10
|
+
from more_transformations._shapes import as_float
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def check_unit(unit: str) -> None:
|
|
14
|
+
"""Raise ``ValueError`` unless ``unit`` is ``"deg"`` or ``"rad"``."""
|
|
15
|
+
if unit not in ("deg", "rad"):
|
|
16
|
+
raise ValueError("Unit must be 'deg' or 'rad'.")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def to_rad(angle: ArrayLike, unit: str) -> np.float64 | NDArray[np.float64]:
|
|
20
|
+
"""Angle in ``unit`` to radians."""
|
|
21
|
+
check_unit(unit)
|
|
22
|
+
angle = as_float(angle)
|
|
23
|
+
return np.radians(angle) if unit == "deg" else angle
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def from_rad(angle: ArrayLike, unit: str) -> Any:
|
|
27
|
+
"""Angle in radians to ``unit``."""
|
|
28
|
+
check_unit(unit)
|
|
29
|
+
return np.degrees(angle) if unit == "deg" else angle
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# file generated by vcs-versioning
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"__version__",
|
|
7
|
+
"__version_tuple__",
|
|
8
|
+
"version",
|
|
9
|
+
"version_tuple",
|
|
10
|
+
"__commit_id__",
|
|
11
|
+
"commit_id",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
version: str
|
|
15
|
+
__version__: str
|
|
16
|
+
__version_tuple__: tuple[int | str, ...]
|
|
17
|
+
version_tuple: tuple[int | str, ...]
|
|
18
|
+
commit_id: str | None
|
|
19
|
+
__commit_id__: str | None
|
|
20
|
+
|
|
21
|
+
__version__ = version = '1.0.0'
|
|
22
|
+
__version_tuple__ = version_tuple = (1, 0, 0)
|
|
23
|
+
|
|
24
|
+
__commit_id__ = commit_id = 'g2f5cebfb0'
|