forked from rai-opensource/spatialmath-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_types_35.py
More file actions
150 lines (129 loc) · 3.58 KB
/
_types_35.py
File metadata and controls
150 lines (129 loc) · 3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# for Python <= 3.8
from typing import (
overload,
Union,
List,
Tuple,
Type,
TextIO,
Any,
Callable,
Optional,
Iterator,
)
from typing_extensions import Literal as L
from typing_extensions import Self
# array like
# these are input to many functions in spatialmath.base, and can be a list, tuple or
# ndarray. The elements are generally float, but some functions accept symbolic
# arguments as well, which leads to a NumPy array with dtype=object
#
# The variants like ArrayLike2 indicate that a list, tuple or ndarray of length 2 is
# expected. Static checking of tuple length is possible but not a lists. This might be
# possible in future versions of Python, but for now it is a hint to the coder about
# what is expected
from numpy.typing import DTypeLike, NDArray # , ArrayLike
from typing import cast
# from typing import TypeVar
# NDArray = TypeVar('NDArray')
import numpy as np
ArrayLike = Union[float, List[float], Tuple[float, ...], NDArray]
ArrayLikePure = Union[List[float], Tuple[float, ...], NDArray]
ArrayLike2 = Union[List, Tuple[float, float], NDArray]
ArrayLike3 = Union[List, Tuple[float, float, float], NDArray]
ArrayLike4 = Union[List, Tuple[float, float, float, float], NDArray]
ArrayLike6 = Union[List, Tuple[float, float, float, float, float, float], NDArray]
# real vectors
R1 = NDArray[np.floating] # R^1
R2 = NDArray[np.floating] # R^2
R3 = NDArray[np.floating] # R^3
R4 = NDArray[np.floating] # R^4
R6 = NDArray[np.floating] # R^6
R8 = NDArray[np.floating] # R^8
# real matrices
R1x1 = NDArray # R^{1x1} matrix
R2x2 = NDArray # R^{3x3} matrix
R3x3 = NDArray # R^{3x3} matrix
R4x4 = NDArray # R^{4x4} matrix
R6x6 = NDArray # R^{6x6} matrix
R8x8 = NDArray # R^{8x8} matrix
R1x3 = NDArray # R^{1x3} row vector
R3x1 = NDArray # R^{3x1} column vector
R1x2 = NDArray # R^{1x2} row vector
R2x1 = NDArray # R^{2x1} column vector
Points2 = NDArray # R^{2xN} matrix
Points3 = NDArray # R^{2xN} matrix
RNx3 = NDArray # R^{Nx3} matrix
# Lie group elements
SO2Array = NDArray # SO(2) rotation matrix
SE2Array = NDArray # SE(2) rigid-body transform
SO3Array = NDArray # SO(3) rotation matrix
SE3Array = NDArray # SE(3) rigid-body transform
# Lie algebra elements
so2Array = NDArray # so(2) Lie algebra of SO(2), skew-symmetrix matrix
se2Array = NDArray # se(2) Lie algebra of SE(2), augmented skew-symmetrix matrix
so3Array = NDArray # so(3) Lie algebra of SO(3), skew-symmetrix matrix
se3Array = NDArray # se(3) Lie algebra of SE(3), augmented skew-symmetrix matrix
# quaternion arrays
QuaternionArray = NDArray
UnitQuaternionArray = NDArray
Rn = Union[R2, R3]
SOnArray = Union[SO2Array, SO3Array]
SEnArray = Union[SE2Array, SE3Array]
sonArray = Union[so2Array, so3Array]
senArray = Union[se2Array, se3Array]
# __all__ = [
# overload,
# Union,
# List,
# Tuple,
# Type,
# TextIO,
# Any,
# Callable,
# Optional,
# Iterator,
# ArrayLike,
# ArrayLike2,
# ArrayLike3,
# ArrayLike4,
# ArrayLike6,
# # real vectors
# R2,
# R3,
# R4,
# R6,
# R8,
# # real matrices
# R2x2,
# R3x3,
# R4x4,
# R6x6,
# R8x8,
# R1x3,
# R3x1,
# R1x2,
# R2x1,
# Points2,
# Points3,
# RNx3,
# # Lie group elements
# SO2Array,
# SE2Array,
# SO3Array,
# SE3Array,
# # Lie algebra elements
# so2Array,
# se2Array,
# so3Array,
# se3Array,
# # quaternion arrays
# QuaternionArray,
# UnitQuaternionArray,
# Rn,
# SOnArray,
# SEnArray,
# sonArray,
# senArray,
# ]
Color = Union[str, ArrayLike3]