|
|
|
@ -3,8 +3,13 @@
@@ -3,8 +3,13 @@
|
|
|
|
|
* |
|
|
|
|
* All rotations and axis systems follow the right-hand rule. |
|
|
|
|
* |
|
|
|
|
* A quaternion instance of this class describes a rotation from |
|
|
|
|
* coordinate frame 1 to coordinate frame 2. The first element of the quaternion |
|
|
|
|
* In order to rotate a vector v by a righthand rotation defined by the quaternion q |
|
|
|
|
* one can use the following operation: |
|
|
|
|
* v_rotated = q^(-1) * [0;v] * q |
|
|
|
|
* where q^(-1) represents the inverse of the quaternion q. |
|
|
|
|
* The product z of two quaternions z = q1 * q2 represents an intrinsic rotation |
|
|
|
|
* in the order of first q1 followed by q2. |
|
|
|
|
* The first element of the quaternion |
|
|
|
|
* represents the real part, thus, a quaternion representing a zero-rotation |
|
|
|
|
* is defined as (1,0,0,0). |
|
|
|
|
* |
|
|
|
@ -83,52 +88,6 @@ public:
@@ -83,52 +88,6 @@ public:
|
|
|
|
|
*/ |
|
|
|
|
Quaternion(const Dcm<Type> & dcm) : |
|
|
|
|
Vector<Type, 4>() |
|
|
|
|
{ |
|
|
|
|
set_from_dcm(dcm); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructor from euler angles |
|
|
|
|
* |
|
|
|
|
* This sets the instance to a quaternion representing coordinate transformation from |
|
|
|
|
* frame 2 to frame 1 where the rotation from frame 1 to frame 2 is described |
|
|
|
|
* by a 3-2-1 intrinsic Tait-Bryan rotation sequence. |
|
|
|
|
* |
|
|
|
|
* @param euler euler angle instance |
|
|
|
|
*/ |
|
|
|
|
Quaternion(const Euler<Type> & euler) : |
|
|
|
|
Vector<Type, 4>() |
|
|
|
|
{ |
|
|
|
|
set_from_euler(euler); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructor from quaternion values |
|
|
|
|
* |
|
|
|
|
* Instance is initialized from quaternion values representing coordinate |
|
|
|
|
* transformation from frame 2 to frame 1. |
|
|
|
|
* A zero-rotation quaternion is represented by (1,0,0,0). |
|
|
|
|
* |
|
|
|
|
* @param a set quaternion value 0 |
|
|
|
|
* @param b set quaternion value 1 |
|
|
|
|
* @param c set quaternion value 2 |
|
|
|
|
* @param d set quaternion value 3 |
|
|
|
|
*/ |
|
|
|
|
Quaternion(Type a, Type b, Type c, Type d) : |
|
|
|
|
Vector<Type, 4>() |
|
|
|
|
{ |
|
|
|
|
set_from_quaternion(a, b, c, d); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set from dcm |
|
|
|
|
* |
|
|
|
|
* Instance is set from a dcm representing coordinate transformation |
|
|
|
|
* from frame 2 to frame 1. |
|
|
|
|
* |
|
|
|
|
* @param dcm dcm to set quaternion to |
|
|
|
|
*/ |
|
|
|
|
void set_from_dcm(const Dcm<Type> & dcm) |
|
|
|
|
{ |
|
|
|
|
Quaternion &q = *this; |
|
|
|
|
q(0) = Type(0.5 * sqrt(1 + dcm(0, 0) + |
|
|
|
@ -142,15 +101,16 @@ public:
@@ -142,15 +101,16 @@ public:
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set from euler angles |
|
|
|
|
* Constructor from euler angles |
|
|
|
|
* |
|
|
|
|
* This sets the instance to a quaternion representing coordinate transformation from |
|
|
|
|
* frame 2 to frame 1 where the rotation from frame 1 to frame 2 is described |
|
|
|
|
* by a 3-2-1 intrinsic Tait-Bryan rotation sequence. |
|
|
|
|
* |
|
|
|
|
* @param euler euler angles to set quaternion to |
|
|
|
|
* @param euler euler angle instance |
|
|
|
|
*/ |
|
|
|
|
void set_from_euler(const Euler<Type> & euler) |
|
|
|
|
Quaternion(const Euler<Type> & euler) : |
|
|
|
|
Vector<Type, 4>() |
|
|
|
|
{ |
|
|
|
|
Quaternion &q = *this; |
|
|
|
|
Type cosPhi_2 = Type(cos(euler.phi() / (Type)2.0)); |
|
|
|
@ -170,17 +130,19 @@ public:
@@ -170,17 +130,19 @@ public:
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set from quaternion values |
|
|
|
|
* Constructor from quaternion values |
|
|
|
|
* |
|
|
|
|
* Instance is set from quaternion values representing coordinate |
|
|
|
|
* Instance is initialized from quaternion values representing coordinate |
|
|
|
|
* transformation from frame 2 to frame 1. |
|
|
|
|
* A zero-rotation quaternion is represented by (1,0,0,0). |
|
|
|
|
* |
|
|
|
|
* @param a set quaternion value 0 |
|
|
|
|
* @param b set quaternion value 1 |
|
|
|
|
* @param c set quaternion value 2 |
|
|
|
|
* @param d set quaternion value 3 |
|
|
|
|
*/ |
|
|
|
|
void set_from_quaternion(Type a, Type b, Type c, Type d) |
|
|
|
|
Quaternion(Type a, Type b, Type c, Type d) : |
|
|
|
|
Vector<Type, 4>() |
|
|
|
|
{ |
|
|
|
|
Quaternion &q = *this; |
|
|
|
|
q(0) = a; |
|
|
|
|