We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b230152 commit 984ab1cCopy full SHA for 984ab1c
LoopStructural/datatypes/_bounding_box.py
@@ -668,3 +668,23 @@ def __eq__(self, other):
668
and np.allclose(self.maximum, other.maximum)
669
and np.allclose(self.nsteps, other.nsteps)
670
)
671
+
672
+ def matrix(self, normalise: bool = False) -> np.ndarray:
673
+ """Get the transformation matrix from local to global coordinates
674
675
+ Returns
676
+ -------
677
+ np.ndarray
678
+ 4x4 transformation matrix
679
+ """
680
+ matrix = np.eye(4)
681
+ L = self.global_maximum - self.global_origin
682
+ L = np.max(L)
683
+ matrix[0, 3] = -self.global_origin[0]/L
684
+ matrix[1, 3] = -self.global_origin[1]/L
685
+ matrix[2, 3] = -self.global_origin[2]/L
686
+ if normalise:
687
+ matrix[0,0] = 1/L
688
+ matrix[1,1] = 1/L
689
+ matrix[2,2] = 1/L
690
+ return matrix
0 commit comments