I’ve this angular velocity vector in Euler form with Degree per second.
What I have to do is that rotate the current BoxComponent by this velocity each tick.
What I’m trying to do is derive the AngularVelocity to get new Orientation Rotator using Quaternion (The formula is dq/dt = spin = 0.5 w q that I took from this link: http://gafferongames.com/game-physics/physics-in-3d/
The problem is that this formula doesn’t work for me.
The code I’ve written is:
FQuat CurrentRotation( BoxComponent->GetComponentQuat() ); FQuat QuatAngularVel(TORAD(AngularVelocity.X), TORAD(AngularVelocity.Y), TORAD(AngularVelocity.Z), 0); // Representation of Angular velocity in quaternion FQuat DeltaSpin((QuatAngularVel*0.5)*CurrentRotation); FRotator NewOrientation = DeltaSpin.Rotator();
What I think is that AngularVelocity vector is not parsed correctly to Quaternion form, So what is the correct way of rotate a BoxComponent each Tick by a Vector velocity using FQuat and avoid Gimbal lock?