Visual Computing Library
Loading...
Searching...
No Matches
vcl::Quaternion< Scalar > Class Template Reference

Quaternion class. More...

#include <vclib/space/core/quaternion.h>

Inheritance diagram for vcl::Quaternion< Scalar >:

Public Types

using ScalarType = Scalar
 The Scalar type of the Quaternion.
 

Public Member Functions

 Quaternion ()
 Constructs a quaternion representing the identity rotation (w = 1, 0, 0, 0).
 
template<typename S , int Options>
 Quaternion (const Eigen::Quaternion< S, Options > &q)
 
 Quaternion (const Scalar &angle, const Point3< Scalar > &axis)
 
 Quaternion (const Matrix44< Scalar > &rotMatrix)
 
 Quaternion (const Point3< Scalar > &a, const Point3< Scalar > &b)
 Constructs the quaternion that will represent the rotation between the two arbitrary vectors a and b.
 
template<typename S >
auto cast () const
 Casts the Quaternion object to a different scalar type.
 
constexpr uint size () const
 
void set (const Scalar &w, const Scalar &x, const Scalar &y, const Scalar &z)
 
void setFromAngleAxis (const Scalar &angle, const Point3< Scalar > &axis)
 
std::size_t hash () const
 Computes the hash value of the quaternion.
 
Point3< Scalar > operator* (const Point3< Scalar > &p) const
 Quaternion-Vector multiplication.
 

Private Types

using Base = Eigen::Quaternion< Scalar >
 

Detailed Description

template<typename Scalar>
class vcl::Quaternion< Scalar >

Quaternion class.

This class represents a quaternion, w + xi + yj + zk vector with a scalar part and a vector part.

Note that the scalar part is stored in the w component, while the vector part is stored in the x, y and z components.

Note
Note that internally the coefficients are stored in the following order: [x, y, z, w]. This means that accessing to the first component of the quaternion (index 0) will return the x component, and the last component (index 3) will return the w component.
Template Parameters
Scalarthe scalar used to represent the quaternion.

Constructor & Destructor Documentation

◆ Quaternion()

template<typename Scalar >
vcl::Quaternion< Scalar >::Quaternion ( const Point3< Scalar > &  a,
const Point3< Scalar > &  b 
)
inline

Constructs the quaternion that will represent the rotation between the two arbitrary vectors a and b.

In other words, the built rotation represent a rotation sending the line of direction a to the line of direction b, both lines passing through the origin.

Parameters
[in]afirst input vector.
[in]bsecond input vector.

Member Function Documentation

◆ cast()

template<typename Scalar >
template<typename S >
auto vcl::Quaternion< Scalar >::cast ( ) const
inline

Casts the Quaternion object to a different scalar type.

The function returns a new Quaternion object with each scalar value casted to a different type.

Template Parameters
SThe scalar type to cast to.
Returns
A new Quaternion object with each scalar value casted to a different type.

◆ hash()

template<typename Scalar >
std::size_t vcl::Quaternion< Scalar >::hash ( ) const
inline

Computes the hash value of the quaternion.

This function computes a hash value of the quaternion, which can be used for hashing and comparison purposes.

Returns
The hash value of the quaternion.

◆ operator*()

template<typename Scalar >
Point3< Scalar > vcl::Quaternion< Scalar >::operator* ( const Point3< Scalar > &  p) const
inline

Quaternion-Vector multiplication.

Corresponds to the operation q * v * q^{-1} where q is the quaternion and v is the vector.

Parameters
[in]pThe vector to rotate.
Returns
The rotated vector.

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