July 05, 2020, 01:48:10 PM

Author Topic: Modifying the quaternions? (In the context of body rotation for Newton physics)  (Read 1289 times)

Offline NoNameHere

  • Jr. Member
  • **
  • Posts: 9
Hello everyone.

I've been trying to do some physics in OpenB3D with the use of newton.dynamics module, and it mostly works but has a little problem with rotations. A GIF would do a good job to show: https://imgur.com/a/Tlh3Olo

Notice how the cubes sort of twitch?

My only guess is that it's happening because i'm using pitch, yaw and roll to do the rotation, and it is prone to gimbal locking. I've tried to dig around in the OpenB3D source looking for a way to rotate the object using a quaternion, but didn't come up with anything that works.

Here's my code: https://gist.github.com/AXKuhta/2406f722c7ffb3ca24ce79b4be613fe1

Offline NoNameHere

  • Jr. Member
  • **
  • Posts: 9
Re: Modifying the quaternions?
« Reply #1 on: November 25, 2019, 02:11:52 PM »
I wasn't reading the source code well enough!

OpenB3D has a function specifically to get the body coordinates from Newton: MQ_ApplyNewtonTransform_()

I've updated my code on github gist to use it, and it seems to work properly now. EDIT: No, there's still something odd happening; it seems that the cubes have their Z-axis inverted now.

P.S.: said code is under WTFPL, you can take it if you need it :)

Offline Kippykip

  • Full Member
  • ***
  • Posts: 118
    • Kippykip Forums!
woah this is pretty cool, you consider ever putting examples on using physics in OpenB3D?


SimplePortal 2.3.6 © 2008-2014, SimplePortal