-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathutils.py
More file actions
23 lines (18 loc) · 756 Bytes
/
utils.py
File metadata and controls
23 lines (18 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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)
#S = np.zeros((3, 3)) # TODO: Create the cross product matrix
S=np.array([[0,-vector[2],vector[1]],
[vector[2],0,-vector[0]],
[-vector[1],vector[0],0]])
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