Archived

This topic is now archived and is closed to further replies.

QUATERNION EXPERTS - Can I ask you a question

This topic is 5658 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hi. I''ve read some stuff on quaternions but I''ve never actually implemented anything in it. I just know some theory. Now, I am going to simulate a suspension system in my racing car. I would like to use quaternions for this purpose but I am not sure exactly which parts of my suspension should be simulated using quaternions. I am writing this app in DirectX and normally I would use matrices all over the place as this is whats available in DirectX but now if I want to use quaternions then which part of the whole suspension system should I use quaternions for. I guess anywhere I use an integrator (RK4) but how about wheels. Does it make sense to use them for wheels too? Thank you for help in advance!

Share on other sites
quaternions for what? all the quaternions do is replace rotational matrices. If you want to use them, use them wherever you use matrices for rotation and orientation. I think you might be a bit confused about quaternions. The main advantages of quats is that they take less memory, can be interpolated, keep their composure much better than matrices, don''t suffer from Gimbal lock (?), they can be converted to matrices, and matrice can be converted to quaternions, quaternion operations are simpler. They are nice little things, although a bit abstract.

For your suspension, I''d guess, you could use them to compute the orientation of your suspension using the two end points.

void CalculateOrientation(const Vector &OriginalDirection, const Vector &NewDirection){	float	CosTheta = OriginalDirection * NewDirection;	float   CosTd2Sq = (CosTheta + 1.0f) * 0.5f;	float   CosTd2   = SquareRoot(CosTd2Sq);	float   SinTd2   = SquareRoot(1.0f - CosTd2Sq);        Vector RotAxis = OriginalDirection.Cross(NewDirection);	RotAxis.Normalise();	this->r = CosTd2;	this->V = RotAxis * SinTd2;}

Share on other sites
To "oliii"
take a look at nice implementation:
http://sourceforge.net/forum/forum.php?forum_id=122133

Share on other sites
cheers.

inline void Quaternion::Rotation(const Vector& from, const Vector& to) {     Vector c = from.Cross(to);     float  d = from.Dot(to);         if (fabs(d) > 0.9999999f)     {         V.Zero();         r = Sign(d);         return;    }    df = from.GetLengthSquared();    dt =   to.GetLengthSquared();    MyAssert(df > 0.000000001f && dt > 0.0000000001f, "Vectors are bollocked. foo!");    this->V  = C;    this->r  = d + SquareRoot(df* dt);       Normalise();}

does that seems fair?

[edited by - oliii on June 20, 2003 6:42:35 PM]

Share on other sites
to "oliii"
Almost perfect ! but

if (fabs(d) > 0.9999999f)
{
V.Zero();
r = Sign(d);
return;
}
not rotate in case of 180 degrees .

Can do so:
if ( d < 0.9999999f )
{
r = 0;
if( ( from.z*from.z ) > ( from.x*from.x ) ) V = from.Cross(Vector(1,0,0));
else V = from.Cross(Vector(0,0,1));
Normalise();
return;
}
just take a SOME rotation axe perpendicular to "from" and ratate by that.

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
5. 5
A4L
11

• 9
• 12
• 16
• 26
• 10
• Forum Statistics

• Total Topics
633769
• Total Posts
3013754
×