Skip to content

Instantly share code, notes, and snippets.

@akiross
Created December 3, 2018 09:53
Show Gist options
  • Save akiross/35cfd7dc29dbdd69bc07a8940201b995 to your computer and use it in GitHub Desktop.
Save akiross/35cfd7dc29dbdd69bc07a8940201b995 to your computer and use it in GitHub Desktop.
Plot rotation against x,y (similar to gnuplot surface rotation)
# 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