forked from K0lb3/UnityPy
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathQuaternion.py
More file actions
32 lines (27 loc) · 847 Bytes
/
Quaternion.py
File metadata and controls
32 lines (27 loc) · 847 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
26
27
28
29
30
31
32
from dataclasses import dataclass
@dataclass
class Quaternion:
X: float
Y: float
Z: float
W: float
def __init__(self, x: float = 0.0, y: float = 0.0, z: float = 0.0, w: float = 1.0):
if not all(isinstance(v, (int, float)) for v in (x, y, z, w)):
raise TypeError("All components must be numeric.")
self.X = float(x)
self.Y = float(y)
self.Z = float(z)
self.W = float(w)
def __getitem__(self, index):
return (self.X, self.Y, self.Z, self.W)[index]
def __setitem__(self, index, value):
if index == 0:
self.X = value
elif index == 1:
self.Y = value
elif index == 2:
self.Z = value
elif index == 3:
self.W = value
else:
raise IndexError("Index out of range")