-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
25 lines (20 loc) · 753 Bytes
/
Copy pathutils.py
File metadata and controls
25 lines (20 loc) · 753 Bytes
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
import numpy as np
from mytypes import ArrayLike
def cross_product_matrix(n: ArrayLike, debug: bool = True) -> np.ndarray:
assert len(n) == 3, f"utils.cross_product_matrix: Vector not of length 3: {n}"
vector = np.array(n, dtype=float).reshape(3)
n1 = vector[0]
n2 = vector[1]
n3 = vector[2]
S = np.array([[0, -n3, n2],
[n3, 0, -n1],
[-n2, n1, 0]]) # Create the cross product matrix
if debug:
assert S.shape == (
3,
3,
), f"utils.cross_product_matrix: Result is not a 3x3 matrix: {S}, \n{S.shape}"
assert np.allclose(
S.T, -S
), f"utils.cross_product_matrix: Result is not skew-symmetric: {S}"
return S