Jump to content

Matrix and quaternion to degrees problem


Recommended Posts

Hello,

I'm trying to automate cogs rotation using vex and a formula I've found online. 

The basic scenario is the following : one cog 'parent' and one cog 'child'. The cog 'parent' is animated (simple animation on Y axis) and will drive the cog 'child' by the following formula : (cog 'parent') * (-cog 'parent'  teeth / cog 'child' teeth) this is quite easy. 

In the example I provided I 'hardcoded' the teeth count but it is calculated procedurally in a larger setup. 

All my cogs are packed primitive so I used matrices to modify their rotation. The main problem is when I extract the rotation of the cog 'parent' to modify it, converting the matrix4 into a matrix3 then into a quaternion then into Euler then into degree, it looks like the angle in degree can't go beyond 360°. The rotation in degrees takes weird values. At the frame 87 the extracted rotation Y of the cog 'parent' is 89.5836 degrees  but at the frame 88 it's -269.375 which is the same value of angle (90° = 270°) but since the cog 'child' is not symmetrical I can see 'jumping' and If I calculate velocity on top of that the vector between these two frames will be wrong.  The value at the frame 88 should be 90.625 not -269.375. I feel like the conversion doesn't allow for value bigger than 360°. I feel like I'm missing on a small thing that can be easily fixed. 

Is there a solution ? 

I've tried putting a modulo 360 somewhere but that didn't change anything

I've tried dealing only with matrices without converting them but that's out of my knowledge (multiplying the rotation matrices by the ratio driven/driving so (cog 'child' teeth / cog 'parent' teeth) .

Thank you for your time, 

Stay safe.

cogs_automation_problem.hiplc

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...