1

How can i correctly interpolate between 2 euler angles with a given time (or velocity)?

For instance, i want to implement a simple blink, rotating the lids first down and then up again. The time a blink takes should be between 50 and 500ms. At the moment i simply calculate the x value(for down) :

Eigen::Vector3f rotateLeftLidDown(float step)
{
return Eigen::Vector3f(-step*COMPLETE_CLOSURE,0,0);
}


//INTERPOLATION
float duration =gen_random_float(0.05f,0.5f);
  for(float i=0;i<1;i=i+(duration))
{
 LeftLid.push_back(rotateLeftLidDown(i));
}

 for(float i=1;i>0;i=i-(duration))
  {
    LeftLid.push_back(rotateLeftLidUp(i));
  }

Every calculating step is later popped from the sack and applied to the nodes at a 100hertz rate.. this approach can blink fast or slow, but it just doesnot seem right. I dont consider the speed of the eyelids and also the "interpolating" here is really dirty...is it better to transform the euler into quaternions or rotation matrices?

A function like blink(500ms), that considers a peak velocity for downward 280mm/s within 70ms and open the eyelid with about 100mm/s would really help me.

EBBLER
  • 11
  • 3
  • I'm not clear what you are actually asking here. Are you asking about the maths or the code? – doctorlove Jul 11 '13 at 09:38
  • possible duplicate of [Interpolating between rotation matrices](http://stackoverflow.com/questions/5580283/interpolating-between-rotation-matrices) – Ali Jul 11 '13 at 10:07
  • im asking about the code how to correctly implement something like blinking with a given velocity and duration of the blink – EBBLER Jul 11 '13 at 10:11

1 Answers1

0

I assume this is 3d? In that case use quaternions to represent your orientation in space. Then interpolation is just simple interpolation of the quaternions.

  • how is this supposed to help me? im asking about this "simple interpolation" with respective duration and velocity – EBBLER Jul 11 '13 at 12:08
  • Because using quats is simpler than trying to deal with euler angles, as all directions are equal whereas in euler angles they are not. – joojaa Jul 20 '13 at 12:15