#include <yarp/math/Quaternion.h>
Inheritance diagram for yarp::math::Quaternion:Public Member Functions | |
| Quaternion () | |
| Quaternion (double x, double y, double z, double w) | |
| double | x () const |
| double | y () const |
| double | z () const |
| double | w () const |
| double & | x () |
| double & | y () |
| double & | z () |
| double & | w () |
| std::string | toString (int precision=-1, int width=-1) const |
| double | abs () |
| Computes the modulus of the quaternion. | |
| void | normalize () |
| Normalizes the quaternion elements. | |
| bool | isValid () const |
| Check if the quaternion is valid. | |
| Quaternion | inverse () const |
| Computes the inverse of the quaternion. | |
| double | arg () |
| Computes the argument or phase of the quaternion in radians. | |
| void | fromAxisAngle (const yarp::sig::Vector &v) |
| Computes the quaternion from an axis-angle representation. | |
| void | fromAxisAngle (const yarp::sig::Vector &axis, const double &angle) |
| Computes the quaternion from an axis-angle representation. | |
| yarp::sig::Vector | toAxisAngle () |
| void | fromRotationMatrix (const yarp::sig::Matrix &R) |
| Converts a rotation matrix to a quaternion. | |
| yarp::sig::Matrix | toRotationMatrix4x4 () const |
| Converts a quaternion to a rotation matrix. | |
| yarp::sig::Matrix | toRotationMatrix3x3 () const |
| Converts a quaternion to a rotation matrix. | |
| yarp::sig::Vector | toVector () const |
| Converts the quaternion to a vector of length 4. | |
Public Member Functions inherited from yarp::sig::QuaternionData | |
| QuaternionData ()=default | |
| QuaternionData (const double q_w, const double q_x, const double q_y, const double q_z) | |
| bool | read (yarp::os::idl::WireReader &reader) override |
| bool | read (yarp::os::ConnectionReader &connection) override |
| Read this object from a network connection. | |
| bool | write (const yarp::os::idl::WireWriter &writer) const override |
| bool | write (yarp::os::ConnectionWriter &connection) const override |
| Write this object to a network connection. | |
| std::string | toString () const |
Public Member Functions inherited from yarp::os::idl::WirePortable | |
| virtual bool | readBare (yarp::os::ConnectionReader &reader) |
| virtual bool | writeBare (yarp::os::ConnectionWriter &writer) const |
| virtual bool | readBottle (yarp::os::ConnectionReader &reader) |
| virtual bool | writeBottle (yarp::os::ConnectionWriter &writer) const |
Public Member Functions inherited from yarp::os::Portable | |
| virtual Type | getType () const |
Public Member Functions inherited from yarp::os::PortReader | |
| virtual | ~PortReader () |
| Destructor. | |
| virtual Type | getReadType () const |
Public Member Functions inherited from yarp::os::PortWriter | |
| virtual | ~PortWriter () |
| Destructor. | |
| virtual void | onCompletion () const |
| This is called when the port has finished all writing operations. | |
| virtual void | onCommencement () const |
| This is called when the port is about to begin writing operations. | |
| virtual yarp::os::Type | getWriteType () const |
Additional Inherited Members | |
Public Types inherited from yarp::sig::QuaternionData | |
| typedef yarp::os::idl::Unwrapped< QuaternionData > | unwrapped |
Static Public Member Functions inherited from yarp::os::Portable | |
| static bool | copyPortable (const PortWriter &writer, PortReader &reader) |
| Copy one portable to another, via writing and reading. | |
Public Attributes inherited from yarp::sig::QuaternionData | |
| double | q_w {0.0} |
| double | q_x {0.0} |
| double | q_y {0.0} |
| double | q_z {0.0} |
Definition at line 18 of file Quaternion.h.
| Quaternion::Quaternion | ( | ) |
Definition at line 19 of file Quaternion.cpp.
| Quaternion::Quaternion | ( | double | x, |
| double | y, | ||
| double | z, | ||
| double | w | ||
| ) |
Definition at line 27 of file Quaternion.cpp.
| double Quaternion::abs | ( | ) |
Computes the modulus of the quaternion.
Definition at line 245 of file Quaternion.cpp.
| double Quaternion::arg | ( | ) |
Computes the argument or phase of the quaternion in radians.
Definition at line 263 of file Quaternion.cpp.
| void Quaternion::fromAxisAngle | ( | const yarp::sig::Vector & | axis, |
| const double & | angle | ||
| ) |
Computes the quaternion from an axis-angle representation.
| axis | a 3D vector representing the axis. @angle the rotation angle (in radians) |
Definition at line 225 of file Quaternion.cpp.
| void Quaternion::fromAxisAngle | ( | const yarp::sig::Vector & | v | ) |
Computes the quaternion from an axis-angle representation.
| v | a 4D vector, where the first three elements represent the axis, while the fourth element represents the angle (in radians) |
Definition at line 214 of file Quaternion.cpp.
| void Quaternion::fromRotationMatrix | ( | const yarp::sig::Matrix & | R | ) |
Converts a rotation matrix to a quaternion.
The returned quaternion is ordered in the following way:

The input rotation matrix and the output quaternion are related by the following formula:
![\[
R(s,r) = I_{3\times3} + 2s r^{\wedge} + 2{r^\wedge}^2,
\]](form_15.png)
where 
![\[
r \times v = r^\wedge v
\]](form_17.png)
| R | the input rotation matrix. |
![\[ \mathbf{q}=q_0 + i \cdot q_1 + j \cdot q_2 +
k \cdot q_3 \]](form_18.png)
Definition at line 94 of file Quaternion.cpp.
| Quaternion Quaternion::inverse | ( | ) | const |
Computes the inverse of the quaternion.
Definition at line 270 of file Quaternion.cpp.
| bool Quaternion::isValid | ( | ) | const |
Check if the quaternion is valid.
Definition at line 35 of file Quaternion.cpp.
| void Quaternion::normalize | ( | ) |
Normalizes the quaternion elements.
Definition at line 253 of file Quaternion.cpp.
| yarp::sig::Vector Quaternion::toAxisAngle | ( | ) |
Definition at line 238 of file Quaternion.cpp.
| yarp::sig::Matrix Quaternion::toRotationMatrix3x3 | ( | ) | const |
Converts a quaternion to a rotation matrix.
| q | the quaternion |
Definition at line 173 of file Quaternion.cpp.
| yarp::sig::Matrix Quaternion::toRotationMatrix4x4 | ( | ) | const |
Converts a quaternion to a rotation matrix.
The quaternion is expected to be ordered in the following way:
The returned rotation matrix is given by the following formula:
![\[
R(s,r) = I_{3\times3} + 2s r^{\wedge} + 2{r^\wedge}^2,
\]](form_15.png)
where 
![\[
r \times v = r^\wedge v
\]](form_17.png)
| q | the 4 by 1 input quaternion in the form
|
Definition at line 154 of file Quaternion.cpp.
| std::string Quaternion::toString | ( | int | precision = -1, |
| int | width = -1 |
||
| ) | const |
Definition at line 192 of file Quaternion.cpp.
| yarp::sig::Vector Quaternion::toVector | ( | ) | const |
Converts the quaternion to a vector of length 4.
Definition at line 44 of file Quaternion.cpp.
| double & Quaternion::w | ( | ) |
Definition at line 74 of file Quaternion.cpp.
| double Quaternion::w | ( | ) | const |
Definition at line 54 of file Quaternion.cpp.
| double & Quaternion::x | ( | ) |
Definition at line 79 of file Quaternion.cpp.
| double Quaternion::x | ( | ) | const |
Definition at line 59 of file Quaternion.cpp.
| double & Quaternion::y | ( | ) |
Definition at line 84 of file Quaternion.cpp.
| double Quaternion::y | ( | ) | const |
Definition at line 64 of file Quaternion.cpp.
| double & Quaternion::z | ( | ) |
Definition at line 89 of file Quaternion.cpp.
| double Quaternion::z | ( | ) | const |
Definition at line 69 of file Quaternion.cpp.