git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@97 92aac97c-a6ce-11dd-a772-7fcde58d38e6
This commit is contained in:
parent
e69f2f98fa
commit
fcc3393777
|
@ -54,6 +54,35 @@ Quaternion::~Quaternion() {
|
|||
|
||||
}
|
||||
|
||||
// Compute the rotation angle (in radians) and the 3D rotation axis
|
||||
// This method is used to get the rotation angle and axis of an
|
||||
// orientation quaternion.
|
||||
// TODO : Test this method
|
||||
void Quaternion::getRotationAngleAxis(double& angle, Vector3D& axis) const {
|
||||
Quaternion quaternion;
|
||||
|
||||
// If the quaternion is unit
|
||||
if (length() == 1.0) {
|
||||
quaternion = *this;
|
||||
}
|
||||
else {
|
||||
// We compute the unit quaternion
|
||||
quaternion = getUnit();
|
||||
}
|
||||
|
||||
// Compute the roation angle
|
||||
angle = acos(quaternion.w) * 2.0;
|
||||
|
||||
// Compute the 3D rotation axis
|
||||
Vector3D rotationAxis(quaternion.x, quaternion.y, quaternion.z);
|
||||
|
||||
// Normalize the rotation axis
|
||||
rotationAxis = rotationAxis.getUnit();
|
||||
|
||||
// Set the rotation axis values
|
||||
axis.setAllValues(rotationAxis.getX(), rotationAxis.getY(), rotationAxis.getZ());
|
||||
}
|
||||
|
||||
// Compute the spherical linear interpolation between two quaternions.
|
||||
// The t argument has to be such that 0 <= t <= 1.
|
||||
// TODO : Test this method
|
||||
|
|
|
@ -62,7 +62,7 @@ class Quaternion
|
|||
Quaternion getConjugate() const; // Return the conjugate quaternion
|
||||
Quaternion getInverse() const throw (MathematicsException); // Return the inverse of the quaternion
|
||||
double scalarProduct(const Quaternion& quaternion) const; // Scalar product between two quaternions
|
||||
|
||||
void getRotationAngleAxis(double& angle, Vector3D& axis) const; // Compute the rotation angle (in radians) and the axis
|
||||
static Quaternion slerp(const Quaternion& quaternion1,
|
||||
const Quaternion& quaternion2, double t); // Compute the spherical linear interpolation between two quaternions
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user