Skip to content

Rotation with a mouse drag #1210

Answered by desiwko
paireks asked this question in Q&A
Jan 10, 2023 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

This functionality is a pretty simple algorithm non-specific to any particular code. Simplified algorithm:

  1. Capture the initial mouse down coordinate
  2. Track the mouse move coordinate while mouse down
  3. Calculate the vector between the two points, normalize if/as desired
  4. Create a rotation matrix from calculated vector
  5. Apply rotation matrix to object
  6. On mouse up, break out of the tracking loop

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@paireks
Comment options

Answer selected by Perksey
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1209 on January 10, 2023 21:52.