| OpenCV 5.0.0alpha Open Source Computer Vision

Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions
Quaternion
Core functionality

## Detailed Description

## Classes
class | cv::DualQuat< _Tp >
class | cv::Quat< _Tp >
class | cv::QuatEnum

## Typedefs
using | cv::DualQuatd = DualQuat<double>
using | cv::DualQuatf = DualQuat<float>
using | cv::Quatd = Quat<double>
using | cv::Quatf = Quat<float>

## Enumerations
enum | cv::QuatAssumeType { cv::QUAT_ASSUME_NOT_UNIT , cv::QUAT_ASSUME_UNIT }
| Unit quaternion flag. More...

## Functions
template<typename T >
Quat< T > | cv::acos (const Quat< T > &q)
template<typename T >
Quat< T > | cv::acosh (const Quat< T > &q)
template<typename T >
Quat< T > | cv::asin (const Quat< T > &q)
template<typename T >
Quat< T > | cv::asinh (const Quat< T > &q)
template<typename T >
Quat< T > | cv::atan (const Quat< T > &q)
template<typename T >
Quat< T > | cv::atanh (const Quat< T > &q)
template<typename T >
Quat< T > | cv::cos (const Quat< T > &q)
template<typename T >
Quat< T > | cv::cosh (const Quat< T > &q)
template<typename T >
Quat< T > | cv::crossProduct (const Quat< T > &p, const Quat< T > &q)
template<typename T >
Quat< T > | cv::exp (const Quat< T > &q)
template<typename T >
Quat< T > | cv::inv (const Quat< T > &q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT)
template<typename T >
Quat< T > | cv::log (const Quat< T > &q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT)
template<typename T >
Quat< T > | cv::operator* (const Quat< T > &, const T)
template<typename T >
Quat< T > | cv::operator* (const T, const Quat< T > &)
template<typename _Tp >
std::ostream & | cv::operator<< (std::ostream &, const DualQuat< _Tp > &)
template<typename _Tp >
std::ostream & | cv::operator<< (std::ostream &, const Quat< _Tp > &)
template<typename S >
std::ostream & | cv::operator<< (std::ostream &, const Quat< S > &)
template<typename T >
Quat< T > | cv::power (const Quat< T > &q, const Quat< T > &p, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT)
template<typename T >
Quat< T > | cv::power (const Quat< T > &q, const T x, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT)
template<typename T >
Quat< T > | cv::sin (const Quat< T > &q)
template<typename T >
Quat< T > | cv::sinh (const Quat< T > &q)
template<typename S >
Quat< S > | cv::sqrt (const Quat< S > &q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT)
template<typename T >
Quat< T > | cv::tan (const Quat< T > &q)
template<typename T >
Quat< T > | cv::tanh (const Quat< T > &q)

## Typedef Documentation

## ◆ DualQuatd

using cv::DualQuatd = DualQuat<double>

`#include <opencv2/core/dualquaternion.hpp>`

## ◆ DualQuatf

using cv::DualQuatf = DualQuat<float>

`#include <opencv2/core/dualquaternion.hpp>`

## ◆ Quatd

using cv::Quatd = Quat<double>

`#include <opencv2/core/quaternion.hpp>`

## ◆ Quatf

using cv::Quatf = Quat<float>

`#include <opencv2/core/quaternion.hpp>`

## Enumeration Type Documentation

## ◆ QuatAssumeType

enum cv::QuatAssumeType

`#include <opencv2/core/quaternion.hpp>`

Unit quaternion flag.

Enumerator
QUAT_ASSUME_NOT_UNIT Python: cv.QUAT_ASSUME_NOT_UNIT | This flag is specified by default. If this flag is specified, the input quaternions are assumed to be not unit quaternions. It can guarantee the correctness of the calculations, although the calculation speed will be slower than the flag QUAT_ASSUME_UNIT.
QUAT_ASSUME_UNIT Python: cv.QUAT_ASSUME_UNIT | If this flag is specified, the input quaternions are assumed to be unit quaternions which will save some computations. However, if this flag is specified without unit quaternion, the program correctness of the result will not be guaranteed.

## Function Documentation

## ◆ acos()

template<typename T >

Quat< T > cv::acos | ( | const Quat< T > & | q | ) |

`#include <opencv2/core/quaternion.hpp>`

\[\arccos(q) = -\frac{\boldsymbol{v}}{||\boldsymbol{v}||}arccosh(q)\]

where \(\boldsymbol{v} = [x, y, z].\)

Parameters

  q | a quaternion.

For example

Quatd q(1,2,3,4);
acos(q);
cv::Quat
Definition quaternion.hpp:211
cv::acos
Quat< T > acos(const Quat< T > &q)

## ◆ acosh()

template<typename T >

Quat< T > cv::acosh | ( | const Quat< T > & | q | ) |

`#include <opencv2/core/quaternion.hpp>`

\[arccosh(q) = \ln(q + \sqrt{q^2 - 1})\]

.

Parameters

  q | a quaternion.

For example

Quatd q(1,2,3,4);
acosh(q);
cv::acosh
Quat< T > acosh(const Quat< T > &q)

## ◆ asin()

template<typename T >

Quat< T > cv::asin | ( | const Quat< T > & | q | ) |

`#include <opencv2/core/quaternion.hpp>`

\[\arcsin(q) = -\frac{\boldsymbol{v}}{||\boldsymbol{v}||}arcsinh(q\frac{\boldsymbol{v}}{||\boldsymbol{v}||})\]

where \(\boldsymbol{v} = [x, y, z].\)

Parameters

  q | a quaternion.

For example

Quatd q(1,2,3,4);
asin(q);
cv::asin
Quat< T > asin(const Quat< T > &q)

## ◆ asinh()

template<typename T >

Quat< T > cv::asinh | ( | const Quat< T > & | q | ) |

`#include <opencv2/core/quaternion.hpp>`

\[arcsinh(q) = \ln(q + \sqrt{q^2 + 1})\]

.

Parameters

  q | a quaternion.

For example

Quatd q(1,2,3,4);
asinh(q);
cv::asinh
Quat< T > asinh(const Quat< T > &q)

## ◆ atan()

template<typename T >

Quat< T > cv::atan | ( | const Quat< T > & | q | ) |

`#include <opencv2/core/quaternion.hpp>`

\[\arctan(q) = -\frac{\boldsymbol{v}}{||\boldsymbol{v}||}arctanh(q\frac{\boldsymbol{v}}{||\boldsymbol{v}||})\]

where \(\boldsymbol{v} = [x, y, z].\)

Parameters

  q | a quaternion.

For example

Quatd q(1,2,3,4);
atan(q);
cv::atan
Quat< T > atan(const Quat< T > &q)

## ◆ atanh()

template<typename T >

Quat< T > cv::atanh | ( | const Quat< T > & | q | ) |

`#include <opencv2/core/quaternion.hpp>`

\[arctanh(q) = \frac{\ln(q + 1) - \ln(1 - q)}{2}\]

.

Parameters

  q | a quaternion.

For example

Quatd q(1,2,3,4);
atanh(q);
cv::atanh
Quat< T > atanh(const Quat< T > &q)

## ◆ cos()

template<typename T >

Quat< T > cv::cos | ( | const Quat< T > & | q | ) |

`#include <opencv2/core/quaternion.hpp>`

\[\cos(p) = \cos(w) * \cosh(||\boldsymbol{v}||) - \sin(w)\frac{\boldsymbol{v}}{||\boldsymbol{v}||}\sinh(||\boldsymbol{v}||)\]

where \(\boldsymbol{v} = [x, y, z].\)

Parameters

  q | a quaternion.

For example

Quatd q(1,2,3,4);
cos(q);
cv::cos
Quat< T > cos(const Quat< T > &q)

## ◆ cosh()

template<typename T >

Quat< T > cv::cosh | ( | const Quat< T > & | q | ) |

`#include <opencv2/core/quaternion.hpp>`

\[\cosh(p) = \cosh(w) * \cos(||\boldsymbol{v}||) + \sinh(w)\frac{\boldsymbol{v}}{||\boldsymbol{v}||}\sin(||\boldsymbol{v}||)\]

where \(\boldsymbol{v} = [x, y, z].\)

Parameters

  q | a quaternion.

For example

Quatd q(1,2,3,4);
cosh(q);
cv::cosh
Quat< T > cosh(const Quat< T > &q)

## ◆ crossProduct()

template<typename T >

Quat< T > cv::crossProduct | ( | const Quat< T > & | p,
|  | const Quat< T > & | q )

`#include <opencv2/core/quaternion.hpp>`

\[p \times q = \frac{pq- qp}{2}\]

\[p \times q = \boldsymbol{u} \times \boldsymbol{v}\]

\[p \times q = (cz-dy)i + (dx-bz)j + (by-xc)k \]

For example

Quatd q{1,2,3,4};
Quatd p{5,6,7,8};
crossProduct(p, q);
cv::crossProduct
Quat< T > crossProduct(const Quat< T > &p, const Quat< T > &q)
cv::Quatd
Quat< double > Quatd
Definition quaternion.hpp:1688

## ◆ exp()

template<typename T >

Quat< T > cv::exp | ( | const Quat< T > & | q | ) |

Python:
| cv.exp( | src[, dst] | ) -> | dst

`#include <opencv2/core/quaternion.hpp>`

\[\exp(q) = e^w (\cos||\boldsymbol{v}||+ \frac{v}{||\boldsymbol{v}||})\sin||\boldsymbol{v}||\]

where \(\boldsymbol{v} = [x, y, z].\)

Parameters

  q | a quaternion.

For example:

Quatd q{1,2,3,4};
cout << exp(q) << endl;
cv::exp
void exp(InputArray src, OutputArray dst)
Calculates the exponent of every array element.

## ◆ inv()

template<typename T >

Quat< T > cv::inv | ( | const Quat< T > & | q,
|  | QuatAssumeType | assumeUnit = QUAT_ASSUME_NOT_UNIT )

`#include <opencv2/core/quaternion.hpp>`

Parameters

  q | a quaternion.
  assumeUnit | if QUAT_ASSUME_UNIT, quaternion q assume to be a unit quaternion and this function will save some computations.

For example

Quatd q(1,2,3,4);
inv(q);
QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT;
q = q.normalize();
inv(q, assumeUnit);//This assumeUnit means p is a unit quaternion
cv::inv
Quat< T > inv(const Quat< T > &q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT)
cv::QuatAssumeType
QuatAssumeType
Unit quaternion flag.
Definition quaternion.hpp:39
cv::QUAT_ASSUME_UNIT
@ QUAT_ASSUME_UNIT
Definition quaternion.hpp:52

## ◆ log()

template<typename T >

Quat< T > cv::log | ( | const Quat< T > & | q,
|  | QuatAssumeType | assumeUnit = QUAT_ASSUME_NOT_UNIT )

Python:
| cv.log( | src[, dst] | ) -> | dst

`#include <opencv2/core/quaternion.hpp>`

\[\ln(q) = \ln||q|| + \frac{\boldsymbol{v}}{||\boldsymbol{v}||}\arccos\frac{w}{||q||}.\]

where \(\boldsymbol{v} = [x, y, z].\)

Parameters

  q | a quaternion.
  assumeUnit | if QUAT_ASSUME_UNIT, q assume to be a unit quaternion and this function will save some computations.

For example

Quatd q1{1,2,3,4};
cout << log(q1) << endl;
cv::log
void log(InputArray src, OutputArray dst)
Calculates the natural logarithm of every array element.

## ◆ operator*() [1/2]

template<typename T >

Quat< T > cv::operator* | ( | const Quat< T > & | ,
|  | const T | )

`#include <opencv2/core/quaternion.hpp>`

## ◆ operator*() [2/2]

template<typename T >

Quat< T > cv::operator* | ( | const T | ,
|  | const Quat< T > & | )

`#include <opencv2/core/quaternion.hpp>`

## ◆ operator<<() [1/3]

template<typename _Tp >

std::ostream & cv::operator<< | ( | std::ostream & | ,
|  | const DualQuat< _Tp > & | )

`#include <opencv2/core/dualquaternion.hpp>`

## ◆ operator<<() [2/3]

template<typename _Tp >

std::ostream & cv::operator<< | ( | std::ostream & | ,
|  | const Quat< _Tp > & | )

`#include <opencv2/core/quaternion.hpp>`

## ◆ operator<<() [3/3]

template<typename S >

std::ostream & cv::operator<< | ( | std::ostream & | ,
|  | const Quat< S > & | )

`#include <opencv2/core/quaternion.hpp>`

## ◆ power() [1/2]

template<typename T >

Quat< T > cv::power | ( | const Quat< T > & | q,
|  | const Quat< T > & | p,
|  | QuatAssumeType | assumeUnit = QUAT_ASSUME_NOT_UNIT )

`#include <opencv2/core/quaternion.hpp>`

\[p^q = e^{q\ln(p)}.\]

Parameters

  p | base quaternion of power function.
  q | index quaternion of power function.
  assumeUnit | if QUAT_ASSUME_UNIT, quaternion \(p\) assume to be a unit quaternion and this function will save some computations.

For example

Quatd p(1,2,3,4);
Quatd q(5,6,7,8);
power(p, q);
QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT;
p = p.normalize();
power(p, q, assumeUnit); //This assumeUnit means p is a unit quaternion
cv::power
Quat< T > power(const Quat< T > &q, const Quat< T > &p, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT)

## ◆ power() [2/2]

template<typename T >

Quat< T > cv::power | ( | const Quat< T > & | q,
|  | const T | x,
|  | QuatAssumeType | assumeUnit = QUAT_ASSUME_NOT_UNIT )

`#include <opencv2/core/quaternion.hpp>`

\[q^x = ||q||(cos(x\theta) + \boldsymbol{u}sin(x\theta))).\]

Parameters

  q | a quaternion.
  x | index of exponentiation.
  assumeUnit | if QUAT_ASSUME_UNIT, quaternion q assume to be a unit quaternion and this function will save some computations.

For example

Quatd q(1,2,3,4);
power(q, 2.0);
QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT;
double angle = CV_PI;
Vec3d axis{0, 0, 1};
Quatd q1 = Quatd::createFromAngleAxis(angle, axis); //generate a unit quat by axis and angle
power(q1, 2.0, assumeUnit);//This assumeUnit means q1 is a unit quaternion.
cv::Quat::createFromAngleAxis
static Quat< _Tp > createFromAngleAxis(const _Tp angle, const Vec< _Tp, 3 > &axis)
from an angle, axis. Axis will be normalized in this function. And it generates
cv::Vec< double, 3 >
CV_PI
#define CV_PI
Definition cvdef.h:382

Note
  the type of the index should be the same as the quaternion.

## ◆ sin()

template<typename T >

Quat< T > cv::sin | ( | const Quat< T > & | q | ) |

`#include <opencv2/core/quaternion.hpp>`

\[\sin(p) = \sin(w) * \cosh(||\boldsymbol{v}||) + \cos(w)\frac{\boldsymbol{v}}{||\boldsymbol{v}||}\sinh(||\boldsymbol{v}||)\]

where \(\boldsymbol{v} = [x, y, z].\)

Parameters

  q | a quaternion.

For example

Quatd q(1,2,3,4);
sin(q);
cv::sin
Quat< T > sin(const Quat< T > &q)

## ◆ sinh()

template<typename T >

Quat< T > cv::sinh | ( | const Quat< T > & | q | ) |

`#include <opencv2/core/quaternion.hpp>`

\[\sinh(p) = \sin(w)\cos(||\boldsymbol{v}||) + \cosh(w)\frac{v}{||\boldsymbol{v}||}\sin||\boldsymbol{v}||\]

where \(\boldsymbol{v} = [x, y, z].\)

Parameters

  q | a quaternion.

For example

Quatd q(1,2,3,4);
sinh(q);
cv::sinh
Quat< T > sinh(const Quat< T > &q)

## ◆ sqrt()

template<typename S >

Quat< S > cv::sqrt | ( | const Quat< S > & | q,
|  | QuatAssumeType | assumeUnit = QUAT_ASSUME_NOT_UNIT )

Python:
| cv.sqrt( | src[, dst] | ) -> | dst

`#include <opencv2/core/quaternion.hpp>`

## ◆ tan()

template<typename T >

Quat< T > cv::tan | ( | const Quat< T > & | q | ) |

`#include <opencv2/core/quaternion.hpp>`

\[\tan(q) = \frac{\sin(q)}{\cos(q)}.\]

Parameters

  q | a quaternion.

For example

Quatd q(1,2,3,4);
tan(q);
cv::tan
Quat< T > tan(const Quat< T > &q)

## ◆ tanh()

template<typename T >

Quat< T > cv::tanh | ( | const Quat< T > & | q | ) |

`#include <opencv2/core/quaternion.hpp>`

\[ \tanh(q) = \frac{\sinh(q)}{\cosh(q)}.\]

Parameters

  q | a quaternion.

For example

Quatd q(1,2,3,4);
tanh(q);
cv::tanh
Quat< T > tanh(const Quat< T > &q)

See also
  sinh, cosh