rotation ramp

Get answers to all your basic programming questions. No Ogre questions, please!
Post Reply
User avatar
Pangamini
Gremlin
Posts: 179
Joined: Fri Sep 17, 2010 2:21 pm
Location: Kosice, Slovakia
x 3
Contact:

rotation ramp

Post by Pangamini »

Hi there

I am trying to control a rigid body by changing its angular acceleration to reach a certain angle. Basically i need to ramp up to max. angular velocity and then stop at the exact point.
I already have such ramps for linear motion, but this rotation stuff is giving me headaches. I tried solving the problem using the euler angle space, but there was a big problem with gimbal lock.

Most suitable example would be a spinning spaceship that wants to stop pointing in some direction.

Any ideas, anyone solved this before?
Ancient Greeks did have a culture, but they didn't have gasoline.
...and we have gasoline.
User avatar
johnhpus
Platinum Sponsor
Platinum Sponsor
Posts: 1186
Joined: Sat Apr 17, 2004 2:49 am
x 3

Re: rotation ramp

Post by johnhpus »

I'm not sure how it applies to momentum, but if you just want to rotate from one position to another, use Ogre's slerp function and a curved spline for the interpolation factor. That combination should allow you to ramp up and slow down in whatever way you like, and still have a predictable end point.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: rotation ramp

Post by Kojack »

Do you want it to instantly stop or slow down to a stop?
Also, is the destination going to change during the rotation? (Such as a moving target)

If it should slow down and the destination is fixed for the duration of the rotation, you could use an s-curve to control the value of a quaternion slerp.
S-curve is:
b=a*a*(3-2*a)
It takes a value from 0-1 (a) and fits it to a curve with acceleration at the start and deceleration at the end.
User avatar
Pangamini
Gremlin
Posts: 179
Joined: Fri Sep 17, 2010 2:21 pm
Location: Kosice, Slovakia
x 3
Contact:

Re: rotation ramp

Post by Pangamini »

Yes, thanks, but that's exactly what i didn't want ;) Imagine you have side thrusters on a spaceship and you need to calculate which and when are on (applying force) to reach certain rotation AND certain velocity at the same time. Anyway, it took me pretty long time but now it kinda works.
Ancient Greeks did have a culture, but they didn't have gasoline.
...and we have gasoline.
Post Reply