Geogram  Version 1.9.1
A programming library of geometric algorithms
GEO::Quaternion Class Reference

Quaternions are useful for representing rotations. More...

#include <geogram/basic/quaternion.h>

Public Member Functions

 Quaternion ()
 Constructs a new Quaternion.
 
 Quaternion (const Quaternion &rhs)
 Copy-constructs a new Quaternion. More...
 
 Quaternion (double x, double y, double z, double w)
 Constructs a new quaternion from its coefficients. More...
 
 Quaternion (const vec3 &v, double s)
 Constructs a new Quaternion from a vector and a scalar. More...
 
Quaternionoperator= (const Quaternion &q)
 Copies a Quaternion. More...
 
void set (const vec3 &v, double s)
 Sets the coefficients of this quaterion. More...
 
void print (std::ostream &out) const
 Displays this Quaternion. More...
 
mat4 to_matrix () const
 Converts this Quaternion into a matrix. More...
 
void set_angle (double f)
 Sets the rotation angle. More...
 
void scale_angle (double f)
 Scales the rotation angle.
 
double angle () const
 Gets the rotation angle. More...
 
vec3 axis () const
 Gets the axis. More...
 
const vec3v () const
 Gets the vector component. More...
 
double s () const
 Gets the scalar component. More...
 

Static Public Member Functions

static Quaternion spherical_interpolation (const Quaternion &from, const Quaternion &to, double t)
 Computes the interpolation between two quaternions. More...
 

Detailed Description

Quaternions are useful for representing rotations.

This class is inspired by an implementation written by Paul Rademacher, in his glui library.

Definition at line 61 of file quaternion.h.

Constructor & Destructor Documentation

◆ Quaternion() [1/3]

GEO::Quaternion::Quaternion ( const Quaternion rhs)
inline

Copy-constructs a new Quaternion.

Parameters
[in]rhsthe Quaternion to be copied.

Definition at line 74 of file quaternion.h.

◆ Quaternion() [2/3]

GEO::Quaternion::Quaternion ( double  x,
double  y,
double  z,
double  w 
)
inline

Constructs a new quaternion from its coefficients.

Parameters
[in]xa coefficient of the quaternion
[in]ya coefficient of the quaternion
[in]za coefficient of the quaternion
[in]wa coefficient of the quaternion

Definition at line 84 of file quaternion.h.

◆ Quaternion() [3/3]

GEO::Quaternion::Quaternion ( const vec3 v,
double  s 
)
inline

Constructs a new Quaternion from a vector and a scalar.

Parameters
[in]va const reference to the vector
[in]sthe scalalr

Definition at line 95 of file quaternion.h.

Member Function Documentation

◆ angle()

double GEO::Quaternion::angle ( ) const
inline

Gets the rotation angle.

Returns
the angle

Definition at line 156 of file quaternion.h.

◆ axis()

vec3 GEO::Quaternion::axis ( ) const

Gets the axis.

Returns
The axis.

◆ operator=()

Quaternion& GEO::Quaternion::operator= ( const Quaternion q)
inline

Copies a Quaternion.

Parameters
[in]qthe Quaternion to be copied
Returns
a reference to this Quaternion

Definition at line 103 of file quaternion.h.

◆ print()

void GEO::Quaternion::print ( std::ostream &  out) const
inline

Displays this Quaternion.

Parameters
[in]outa reference to the std::ostream where this Quaternion should be displayed

Definition at line 124 of file quaternion.h.

◆ s()

double GEO::Quaternion::s ( ) const
inline

Gets the scalar component.

Returns
the scalar component
Note
the scalar component is not the rotation angle. The rotation angle is obtained by calling angle().

Definition at line 195 of file quaternion.h.

◆ set()

void GEO::Quaternion::set ( const vec3 v,
double  s 
)
inline

Sets the coefficients of this quaterion.

Parameters
[in]va const reference to the vector components
[in]sthe scalar component

Definition at line 114 of file quaternion.h.

◆ set_angle()

void GEO::Quaternion::set_angle ( double  f)
inline

Sets the rotation angle.

Parameters
[in]fthe rotation angle

Definition at line 139 of file quaternion.h.

◆ spherical_interpolation()

static Quaternion GEO::Quaternion::spherical_interpolation ( const Quaternion from,
const Quaternion to,
double  t 
)
static

Computes the interpolation between two quaternions.

Parameters
[in]froma const reference to the first quaternion
[in]toa const reference to the second quaternion
[in]ttime, in [0.0,1.0]
Returns
a smooth interpolation between from and to parameterized by t

◆ to_matrix()

mat4 GEO::Quaternion::to_matrix ( ) const

Converts this Quaternion into a matrix.

Returns
a matrix (mat4) that represents this Quaternion

◆ v()

const vec3& GEO::Quaternion::v ( ) const
inline

Gets the vector component.

Returns
the vector component
Note
the vector part is not the axis of rotation. The axis of rotation is obtained by calling axis().

Definition at line 185 of file quaternion.h.


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