cgse-coordinates 0.17.2__py3-none-any.whl → 0.17.4__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.
@@ -1,82 +0,0 @@
1
- """
2
- The RotationMatrix provides a number of convenience methods to define and apply rotations.
3
-
4
- @author: pierre
5
- """
6
-
7
- import transforms3d as t3
8
- import numpy as np
9
-
10
-
11
- class RotationMatrix:
12
- """
13
- RotationMatrix(angle1, angle2, angle3, rot_config="sxyz", active=True)
14
-
15
- The ``angle`` parameters provide the amplitude of rotation around an axis
16
- according to the order of rotations corresponding to the ``rot_config`` parameter.
17
-
18
- The ``rot_config`` parameter is a string that consists of four letter
19
- indicating the rotation system and the order of applying the rotations. The default
20
- for this parameter is ``"rxyz"`` where the first character can be 'r' or 's' and
21
- the next three characters define the axes of rotation in the order specified, here 'xyz'.
22
-
23
- * 'r' stands for rotating system (intrinsic rotations)
24
- * 's' stands for static system (extrinsic rotations)
25
- * "rxyz" imposes angle1 describes the rotation around X
26
- * even if two angles = 0, the match between angle orders and rot_config is still critical
27
-
28
- :param str rot_config: otation system to be used, 4 characters. Default = "sxyz"
29
-
30
- :param float angle1: amplitude of rotations around the first axis
31
-
32
- :param float angle2: amplitude of rotations around the second axis
33
-
34
- :param float angle3: amplitude of rotations around the third axis
35
-
36
- :param bool active: when True the object rotates **in** a fixed coord system,
37
- when False the coord system rotates **around** a fixed object
38
- The default for the transform3d.euleur package is to represent movements
39
- of the coordinate system itself --> **around** the object <==> passive
40
- """
41
-
42
- _ROT_CONFIG_DEFAULT = "sxyz"
43
-
44
- def __init__(self, angle1, angle2, angle3, rot_config=_ROT_CONFIG_DEFAULT, active=True):
45
- R = t3.euler.euler2mat(angle1, angle2, angle3, rot_config)
46
- if active:
47
- self.R = R
48
- else:
49
- self.R = R.T
50
- rot_config_array = np.array(list(rot_config[1:]))
51
- angles_array = np.array([angle1, angle2, angle3])
52
- self.angles_hash = {}
53
- for axis in ["x", "y", "z"]:
54
- self.angles_hash[axis] = angles_array[np.where(rot_config_array == axis)[0][0]]
55
- self.active = active
56
-
57
- def getRotationMatrix(self):
58
- """Return the Rotation Matrix"""
59
- return self.R
60
-
61
- def trace(self):
62
- return np.sum([self.R[i, i] for i in range(3)])
63
-
64
- def getAngle(self, axis):
65
- """
66
- Returns the angle
67
-
68
- :param str axis: 'x', 'y', 'z'
69
-
70
- :return: the angle
71
- """
72
- return self.angles_hash[axis]
73
-
74
- def apply(self, vectors):
75
- """
76
- if self = active, the output = the coords of these vectors after rotation
77
-
78
- if self = passive, the ouput = the coords of these vectors after transformation to the rotated coordinate system
79
-
80
- :param vectors: an array of shape [3,N] gathering a set of vectors along its columns
81
- """
82
- return np.dot(self.R, vectors)