Created
December 3, 2018 09:53
-
-
Save akiross/35cfd7dc29dbdd69bc07a8940201b995 to your computer and use it in GitHub Desktop.
Plot rotation against x,y (similar to gnuplot surface rotation)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a pseudocode tbh | |
def on_mouse_move(self, pos): | |
# Normalized distance of cursor motion | |
dist = (pos - self.last_mouse_pos) / (win_w, win_h) | |
# Build rotation matrices around | |
# y axis (when moving mouse horizontally) | |
rot_x = rotation_matrix(260 * dist.x(), 0, 1, 0) | |
# x axis (when moving mouse vertically) | |
rot_y = rotation_matrix(260 * dist.y(), 1, 0, 0) | |
# Update rotation matrix, note the order | |
self.rot = rot_y * self.rot * rot_x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment