January 28, 2021, 11:08:05 AM

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

#### NoNameHere

• Jr. Member
• Posts: 9
##### Modifying the quaternions? (In the context of body rotation for Newton physics)
« on: November 19, 2019, 12:58:26 PM »
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

#### 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

#### Kippykip

• Full Member
• Posts: 130
##### Re: Modifying the quaternions? (In the context of body rotation for Newton physics)
« Reply #2 on: February 04, 2020, 11:27:03 AM »
woah this is pretty cool, you consider ever putting examples on using physics in OpenB3D?