Isis 3 Programmer Reference
Isis::Quaternion Class Reference

Provide operations for quaternion arithmetic. More...

#include <Quaternion.h>

Collaboration diagram for Isis::Quaternion:
Collaboration graph

Public Member Functions

 Quaternion ()
 Constructs an empty quaternion. More...
 
 Quaternion (const std::vector< double > matrix)
 Construct a Quaternion class from a matrix stored as a vector < double > with 9 elements or from a quaternion stored as a vector < double > with 4 elements. More...
 
 ~Quaternion ()
 Destroys the Quaternion object. More...
 
std::vector< double > ToMatrix ()
 Converts quaternion to 3x3 rotational matrix. More...
 
std::vector< double > ToAngles (int axis3, int axis2, int axis1)
 Return the camera angles (right ascension, declination, and twist) for the quaternion. More...
 
void Set (std::vector< double >)
 Sets the quaternion value. More...
 
std::vector< double > GetQuaternion () const
 Return the quaternion as a vector. More...
 
Quaternionoperator= (const Quaternion &quat)
 Assign value of quaternion class to another quaternion. More...
 
Quaternionoperator*= (const Quaternion &quat)
 Multiply current Naif quaternion by another Naif quaternion, replacing the current quaternion. More...
 
Quaternion operator* (const Quaternion &quat) const
 Multiply two Naif quaternions to create a new quaternion. More...
 
Quaternion operator* (const double &scalar)
 Multiply a quaternion by a scalar. More...
 
double & operator[] (int index)
 Return a member of a quaternion. More...
 
std::vector< double > Qxv (const std::vector< double > &vin)
 Multiply a vector by a quaternion (rotate the vector) More...
 
Quaternion Conjugate ()
 Returns the conjugate of the quaternion. More...
 

Private Member Functions

void Polish (Quaternion &quat)
 Polish the quaternion – make the first component positive. More...
 

Private Attributes

std::vector< double > p_quaternion
 Quaternion. More...
 

Detailed Description

Provide operations for quaternion arithmetic.

This class provides a wrapper for existing Naif quaternion functions and also includes other operators and methods useful for working with quaternions.

Author
2005-12-07 Debbie A. Cook
History:

????-??-?? Steven Lambright Fixed documentation

2015-07-21 Kristin Berry - Added NaifStatus::CheckErrors() to see if any NAIF errors were signaled. References #2248.

Definition at line 52 of file Quaternion.h.

Constructor & Destructor Documentation

◆ Quaternion() [1/2]

Isis::Quaternion::Quaternion ( )

Constructs an empty quaternion.

Definition at line 42 of file Quaternion.cpp.

References p_quaternion.

◆ Quaternion() [2/2]

Isis::Quaternion::Quaternion ( const std::vector< double >  rotation)

Construct a Quaternion class from a matrix stored as a vector < double > with 9 elements or from a quaternion stored as a vector < double > with 4 elements.

Parameters
rotationrotation defined as either a matrix or another quaternion loaded as a vector

Definition at line 58 of file Quaternion.cpp.

References p_quaternion, and Set().

◆ ~Quaternion()

Isis::Quaternion::~Quaternion ( )

Destroys the Quaternion object.

Definition at line 65 of file Quaternion.cpp.

Member Function Documentation

◆ Conjugate()

Quaternion Isis::Quaternion::Conjugate ( )

Returns the conjugate of the quaternion.

Definition at line 213 of file Quaternion.cpp.

References p_quaternion.

Referenced by Qxv().

◆ GetQuaternion()

std::vector<double> Isis::Quaternion::GetQuaternion ( ) const
inline

Return the quaternion as a vector.

Definition at line 70 of file Quaternion.h.

References p_quaternion.

Referenced by Isis::SpiceRotation::Cache().

◆ operator*() [1/2]

Quaternion Isis::Quaternion::operator* ( const Quaternion quat) const

Multiply two Naif quaternions to create a new quaternion.

For example,

Quaternion q1(),q(2);
...
Quaternion q3() = q1*q2;

More information is available on quaternions and the multiplication algorithm in the Naif routine qxq_c.c

Parameters
[in]quat(const Quaternion &) quaternion to multiply on the right
Returns
(Quaternion) product of quaternions

Definition at line 163 of file Quaternion.cpp.

◆ operator*() [2/2]

Quaternion Isis::Quaternion::operator* ( const double &  scalar)

Multiply a quaternion by a scalar.

Just multiply the rotation part and polish the resulting quaternion so it is still a unit quaternion with positive rotation. For example,

Quaternion q1(),q(2);
double scalar
...
q2() = scalar*q2;
Parameters
[in]scalar(const double &) scalar value to be multiplied times the current quaternion
Returns
(Quaternion) product of scalar and quaternion

Definition at line 188 of file Quaternion.cpp.

References _FILEINFO_, p_quaternion, Polish(), and Isis::IException::Programmer.

◆ operator*=()

Quaternion & Isis::Quaternion::operator*= ( const Quaternion quat)

Multiply current Naif quaternion by another Naif quaternion, replacing the current quaternion.

For example,

Quaternion q1(),q(2);
...
Quaternion q2() *= q1;

More information on quaternions and the multiplication algorithm is available in the Naif routine qxq_c.

Parameters
[in]quat(const Quaternion &) quaternion to multiply on the right
Returns
(Quaternion) product of quaternions

Definition at line 133 of file Quaternion.cpp.

References p_quaternion.

◆ operator=()

Quaternion & Isis::Quaternion::operator= ( const Quaternion quat)

Assign value of quaternion class to another quaternion.

For example,

Quaternion q1( matrix );
...
q2 = q1;
Parameters
quatThe Quaternion to copy

Definition at line 111 of file Quaternion.cpp.

References p_quaternion.

◆ operator[]()

double& Isis::Quaternion::operator[] ( int  index)
inline

Return a member of a quaternion.

For example,

...
double angle = q[0];
Parameters
[in]index(const int &) quaternion member to return
Returns
(double&) value pointed to by iter

Definition at line 95 of file Quaternion.h.

References p_quaternion.

◆ Polish()

void Isis::Quaternion::Polish ( Quaternion quat)
private

Polish the quaternion – make the first component positive.

Definition at line 258 of file Quaternion.cpp.

References p_quaternion.

Referenced by operator*().

◆ Qxv()

std::vector< double > Isis::Quaternion::Qxv ( const std::vector< double > &  vin)

Multiply a vector by a quaternion (rotate the vector)

Parameters
[in]vin(const std::vector<double>(3)) Vector to be multiplied (rotated)

Definition at line 231 of file Quaternion.cpp.

References _FILEINFO_, Conjugate(), p_quaternion, and Isis::IException::Programmer.

◆ Set()

void Isis::Quaternion::Set ( std::vector< double >  rotation)

Sets the quaternion value.

Parameters
rotationrotation defined as either a matrix or a set of 3 angles

Definition at line 72 of file Quaternion.cpp.

References _FILEINFO_, Isis::NaifStatus::CheckErrors(), p_quaternion, and Isis::IException::Programmer.

Referenced by Quaternion().

◆ ToAngles()

std::vector< double > Isis::Quaternion::ToAngles ( int  axis3,
int  axis2,
int  axis1 
)

Return the camera angles (right ascension, declination, and twist) for the quaternion.

Definition at line 276 of file Quaternion.cpp.

References Isis::NaifStatus::CheckErrors(), and ToMatrix().

◆ ToMatrix()

std::vector< double > Isis::Quaternion::ToMatrix ( )

Converts quaternion to 3x3 rotational matrix.

Definition at line 91 of file Quaternion.cpp.

References p_quaternion.

Referenced by ToAngles().

Member Data Documentation

◆ p_quaternion

std::vector<double> Isis::Quaternion::p_quaternion
private

The documentation for this class was generated from the following files: