Added makeRotate(heading,pitch,roll) to Quat in prep for new classes for
animation paths.
This commit is contained in:
parent
260fd17573
commit
7c0eb0f380
@ -210,6 +210,10 @@ class SG_EXPORT Quat
|
||||
are co-incident or opposite in direction.*/
|
||||
void makeRotate( const Vec3& vec1, const Vec3& vec2 );
|
||||
|
||||
/** make a rotation Quat from euler angles.*/
|
||||
void makeRotate( float heading, float pitch, float roll);
|
||||
|
||||
|
||||
/** Return the angle and vector components represented by the quaternion.*/
|
||||
void getRotate ( float& angle, float& x, float& y, float& z ) const;
|
||||
/** Return the angle and vector represented by the quaternion.*/
|
||||
|
@ -149,24 +149,11 @@ void Matrix::makeRotate( const Quat& q )
|
||||
q.get(*this);
|
||||
}
|
||||
|
||||
void Matrix::makeRotate( float yaw, float pitch, float roll)
|
||||
void Matrix::makeRotate( float heading, float pitch, float roll)
|
||||
{
|
||||
|
||||
// lifted straight from SOLID library v1.01 Quaternion.h
|
||||
// available from http://www.win.tue.nl/~gino/solid/
|
||||
// and also distributed under the LGPL
|
||||
float cosYaw = cos(yaw / 2);
|
||||
float sinYaw = sin(yaw / 2);
|
||||
float cosPitch = cos(pitch / 2);
|
||||
float sinPitch = sin(pitch / 2);
|
||||
float cosRoll = cos(roll / 2);
|
||||
float sinRoll = sin(roll / 2);
|
||||
Quat q(sinRoll * cosPitch * cosYaw - cosRoll * sinPitch * sinYaw,
|
||||
cosRoll * sinPitch * cosYaw + sinRoll * cosPitch * sinYaw,
|
||||
cosRoll * cosPitch * sinYaw - sinRoll * sinPitch * cosYaw,
|
||||
cosRoll * cosPitch * cosYaw + sinRoll * sinPitch * sinYaw);
|
||||
|
||||
q.get(*this);
|
||||
Quat quat;
|
||||
quat.makeRotate(heading,pitch,roll);
|
||||
quat.get(*this);
|
||||
}
|
||||
|
||||
void Matrix::mult( const Matrix& lhs, const Matrix& rhs )
|
||||
|
@ -36,6 +36,24 @@ void Quat::makeRotate( const float angle, const Vec3& vec )
|
||||
makeRotate( angle, vec[0], vec[1], vec[2] );
|
||||
}
|
||||
|
||||
void Quat::makeRotate( float heading, float pitch, float roll)
|
||||
{
|
||||
|
||||
// lifted straight from SOLID library v1.01 Quaternion.h
|
||||
// available from http://www.win.tue.nl/~gino/solid/
|
||||
// and also distributed under the LGPL
|
||||
float cosHeading = cos(heading / 2);
|
||||
float sinHeading = sin(heading / 2);
|
||||
float cosPitch = cos(pitch / 2);
|
||||
float sinPitch = sin(pitch / 2);
|
||||
float cosRoll = cos(roll / 2);
|
||||
float sinRoll = sin(roll / 2);
|
||||
set(sinRoll * cosPitch * cosHeading - cosRoll * sinPitch * sinHeading,
|
||||
cosRoll * sinPitch * cosHeading + sinRoll * cosPitch * sinHeading,
|
||||
cosRoll * cosPitch * sinHeading - sinRoll * sinPitch * cosHeading,
|
||||
cosRoll * cosPitch * cosHeading + sinRoll * sinPitch * sinHeading);
|
||||
|
||||
}
|
||||
|
||||
// Make a rotation Quat which will rotate vec1 to vec2
|
||||
// Generally take adot product to get the angle between these
|
||||
|
Loading…
Reference in New Issue
Block a user