rotation matrix and angular velocity

Started by
6 comments, last by John Schultz 19 years ago
Hi! I have a 3x3 rotation matrix 'R' which I obtain by solving the following system: A' = R*A where A and A' are 3xn matrices representing corresponding sets of points that are at unit distance from the origin. By inspection, the matrix R seems correct. I am dealing with small angles, so R is close to identity. What I need is to find the Angular Velocity (i,j,k) that correspond to this rotation matrix. I tried to extract the euler angles (with yaw/pitch/roll convention) directly from the matrix, but I seems to be stuck with numerical problems because of the small angles. Anyone can suggest a different approach? Any help is appreciated, thanks!
Advertisement
Convert to a quaternion, then:

inline Vec3 Quat4::getVelocity(void) const {  const Vec3 & n = (Vec3 &)*this;  return 2.f*n; // Given velQuat = Quat(.5f*vel,0), vel = 2.f*(Vec3 &)velQuat.} // Quat4::getVelocity// To get velocity from the difference between two rotations, I use:// Computes velocity from change in prev to curr.inline Vec3 getLocalRotVelocity(const Quat4 & prev,const Quat4 & curr) {  Quat4 vq = curr ^ !prev; // ^ = quat transform, same effect as matrix multiplication, ! reverses rotation (same effect as matrix transpose).  return vq.getVelocity();} // getLocalRotVelocity// Computes velocity from change in prev to curr.inline Vec3 getLocalRotVelocity(const Mat3 & prev,const Mat3 & curr) {  return getLocalRotVelocity(Quat4(prev),Quat4(curr));} // getLocalRotVelocity
What kind of decomposition are you looking for? Offhand, I can think of three (possibly) useful ones:

1. One rotation per axis (Ri, Rj, Rk) consisiting of the rotation of a point around that axis (after it is projected back into the plane perpendicular to that axis). Note that this is not a true linear decomposition, because R = Ri * Rj * Rk does not hold for an arbitrary rotation.

2. 3 euler angle rotations which comprise a linear decomposition of R, s.t. R = Ri * Rj * Rk ... this is not unique though, and necessitates complicated logic.

3. An axis-angle rotation, i.e. an axis and an angle of rotation around that axis. The easiest way to do this is to use existing formulas which convert a rotation matrix to a quaternion, which is basically an axis-angle representation.

I would guess that 1 and 2 have numerical problems, and 3 is more stable. However it doesn't give you the same information, so it depends what you need it for. It should give you a good value for total angular velocity, which is probably more meaningful in a physical problem than the velocities around the three axes.

Tom
"E-mail is for geeks and pedophiles." -Cruel Intentions
I dont know exactly what I need, thats the problem. I need to use two algorithm from different papers. The first give me the rotation matrix. The second states that I need

"wx, wy, and wz, the components of the rotational velocity around the x, y and z directions"

The guy doesnt even states the units, but only radians make sense with the rest of the paper, so that must be it.
Quote:Original post by Steadtler
I dont know exactly what I need, thats the problem. I need to use two algorithm from different papers. The first give me the rotation matrix. The second states that I need

"wx, wy, and wz, the components of the rotational velocity around the x, y and z directions"

The guy doesnt even states the units, but only radians make sense with the rest of the paper, so that must be it.


The above code will give you angular velocity in "direction cosine" units.

To get radians:

/*Vec3 axis;flt angle;Quat4 q(~Vec3(1,2,3),rDegToRad(.1f));q.getAxisAngle(axis,angle);angle = rRadToDeg(angle);*/inline bool Quat4::getAxisAngle(Vec3 & axis,flt & angle) const {  const Vec3 & n = (Vec3 &)*this;  flt lenSqr = n.lengthSqr();  if (lenSqr > 0.f) {    axis = n*sqrtInverse(lenSqr);  // The sine is encoded in the axis direction.    angle = rAcos(rSqr(w)-lenSqr); // Get the angle: from test code above, this version: .0989 vs .0969 (2*acos(w)).//  angle = 2.f*rAcos(w);//  The combined angle and axis direction negate the need for atan2() to get 2pi range rotation.    return true;      } else {    axis  = Vec3(0,0,1);    angle = 0.f;    return false;  } // if} // getAxisAngle
thanks, I'll try it.
Hi again,

Ok,

Solution 1 gives me values that are too big.
Solution 2 is just incorrect.

Now I've read of a bit on quaternion and tried some of the things...
However, converting to axis-angle like John suggested doesnt gives me only the total velocity. Is there a way with quaternion to specify the axis and get the velocity around that axis?

Thanks,

Steadtler

Quote:Original post by Steadtler
Hi again,

Ok,

Solution 1 gives me values that are too big.
Solution 2 is just incorrect.

Now I've read of a bit on quaternion and tried some of the things...
However, converting to axis-angle like John suggested doesnt gives me only the total velocity. Is there a way with quaternion to specify the axis and get the velocity around that axis?

Thanks,

Steadtler


Are you taking into account delta time?

This topic is closed to new replies.

Advertisement