Skip to content

Commit

Permalink
allow 3d object rotation via rotation matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
falkoschindler committed Sep 9, 2021
1 parent ae51c46 commit 79c7fa9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion nicegui/elements/scene_object3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ def rotate(self, omega: float, phi: float, kappa: float):
Rx = np.array([[1, 0, 0], [0, np.cos(omega), -np.sin(omega)], [0, np.sin(omega), np.cos(omega)]])
Ry = np.array([[np.cos(phi), 0, np.sin(phi)], [0, 1, 0], [-np.sin(phi), 0, np.cos(phi)]])
Rz = np.array([[np.cos(kappa), -np.sin(kappa), 0], [np.sin(kappa), np.cos(kappa), 0], [0, 0, 1]])
R = (Rz @ Ry @ Rx).tolist()
return self.rotate_R((Rz @ Ry @ Rx).tolist())

def rotate_R(self, R: list[list[float]]):
if self.R != R:
self.R = R
self.run_command(self._rotate_command)
Expand Down

0 comments on commit 79c7fa9

Please sign in to comment.