2

In my OpenGL application I need to use ArcBall rotation to rotate objects using mouse.

I relized that I have to go with Quaternions after reading this article - http://www.gamedev.net/page/resources/_/technical/math-and-physics/quaternion-powers-r1095

And I found an easy to use implementation at here - http://www.codeproject.com/KB/openGL/virtualtrackball.aspx

But my problem is I also need to animate my object between saved two status. That is -

State(1)= (Postition X1,Position Y1,Position Z1, Rotation 1);

State(2)= (Postition X2,Position Y2,Position Z2, Rotation 2);

*These 'Rotations' are rotation matrices

And the animation is done in n steps.

Something like shown in this video - http://www.youtube.com/watch?v=rrUCBOlJdt4

If I was using 3 seperate angles for three axises(roll, pitch, yaw) I could easily interpolate the angles. But ,since ArcBall uses rotation Matrix , how can I interpolate the rotations between State 1 and State2 ?

Any suggestions ?

Ashika Umanga Umagiliya
  • 8,988
  • 28
  • 102
  • 185

2 Answers2

4

Use quaternions (SLERP). Neither rotation matrices nor Euler angles are appropriate for interpolation.

See 45:05 here (David Sachs, Google Tech Talk).

See also Interpolating between rotation matrices

Community
  • 1
  • 1
Ali
  • 56,466
  • 29
  • 168
  • 265
2

Either use Matrix or Quaternion for rotation representation internally. With roll/pitch/yaw you could interpolate the angles in theory, but this will not work every time - read up on Gimbal lock.

With Quaternions the rotation interpolation is easy - just interpolate the individual coordinates (just as you would with r/p/y angles), normalizing when necessary. You'd have to then adjust your rendering function to work with quaternions (but I assume you already did that since you mention quaternions youself).

With Matrixes the interpolation is not so nice, I've struggled with it several years back and all I can remember it that I finally decided to go with quaternions. So I can't advice on this, sorry.

Fiktik
  • 1,941
  • 16
  • 25
  • The reasons why you had problems with matrices is, that interpolating rotation of a cartesian coordinate system is not linear independent. You need to move this into some coordinate system where it is. Like cylinder coordinates, whith the cylinder axis being the rotational axis (the same goes for spherical coordinates, but cylinder is less computational expensive). – datenwolf Jan 04 '12 at 09:17