Eidolon
Public Member Functions | Protected Attributes | Friends | List of all members
rotator Class Reference

#include <RenderTypes.h>

Collaboration diagram for rotator:
Collaboration graph

Public Member Functions

 rotator ()
 Default no-op. More...
 
 rotator (const rotator &r)
 Copy constructor. More...
 
 rotator (const vec3 &axis, real rads)
 Defines a rotation about the given axis. More...
 
 rotator (real x, real y, real z, real w)
 Defines a rotator by the given quaternion values. More...
 
 rotator (const vec3 &from, const vec3 &to)
 Defines the rotation which transforms normalized vectors `from' to `to' rotating about their cross product. More...
 
 rotator (real yaw, real pitch, real roll)
 Defines a rotation from Euler angles: yaw = Z-axis rotation, pitch = X-axis rotation, roll = Y-axis rotation. More...
 
 rotator (real m00, real m01, real m02, real m10, real m11, real m12, real m20, real m21, real m22)
 Defines a rotation from the significant 3x3 components of a 4x4 rotation matrix. More...
 
 rotator (vec3 row1, vec3 col1, vec3 row2, vec3 col2)
 
void setAxis (const vec3 &axis, real rads)
 Set the rotator to represent a rotation of `rads' radians around `axis'. More...
 
void set (const rotator &r)
 Copy the values of `r' into `this'. More...
 
void set (real ry, real rz, real rw)
 sets parameters given the normalized quaternion components More...
 
void set (real rx, real ry, real rz, real rw)
 Sets all parameters to those provided. More...
 
real w () const
 
real x () const
 
real y () const
 
real z () const
 
real getPitch () const
 Get the pitch angle (x-axis rotation in radians) More...
 
real getYaw () const
 Get the yaw angle (z-axis rotation in radians) More...
 
real getRoll () const
 Get the roll angle (y-axis rotation in radians) More...
 
vec3 operator* (const vec3 &v) const
 Rotate `v' according to this rotator's parameters. More...
 
vec3 operator/ (const vec3 &v) const
 
rotator operator* (const rotator &r) const
 Returns a rotator representing the rotation `r' followed by `this'. More...
 
rotator operator* (real r) const
 
rotator operator+ (const rotator &r) const
 
rotator operator- (const rotator &r) const
 
rotator operator- () const
 
bool operator== (const rotator &v) const
 
bool operator!= (const rotator &v) const
 
rotator conjugate () const
 
real len () const
 
real dot (const rotator &r) const
 
rotator norm () const
 
void normThis ()
 
rotator inverse () const
 Returns a rotator representing the opposite rotation. More...
 
rotator interpolate (real val, const rotator &r) const
 Semi-linearly interpolates between `this' and `r', this varies from a circular interpolation but is faster. More...
 
void toMatrix (real *mat) const
 
mat4 toMatrix () const
 
i32 hash () const
 

Protected Attributes

real _w
 
real _x
 
real _y
 
real _z
 

Friends

vec3 operator* (const vec3 &v, const rotator &r)
 Commutative version of the above. More...
 
vec3 operator/ (const vec3 &v, const rotator &r)
 Commutative version of the above. More...
 
std::ostream & operator<< (std::ostream &out, const rotator &r)
 

Detailed Description

Quaternion rotator (see http://3dengine.org/Quaternions, http://www.cprogramming.com/tutorial/3d/quaternions.html)

Quaternions represent abitrary affine rotations, usually described as rotations about an given axis vector. The advantage over matrices for rotations is fewer floating point calculations and avoidance of gimbal lock. Note the lack of virtual members implies no vtable pointer.

Constructor & Destructor Documentation

◆ rotator() [1/8]

rotator ( )
inline

Default no-op.

◆ rotator() [2/8]

rotator ( const rotator r)
inline

Copy constructor.

◆ rotator() [3/8]

rotator ( const vec3 axis,
real  rads 
)
inline

Defines a rotation about the given axis.

◆ rotator() [4/8]

rotator ( real  x,
real  y,
real  z,
real  w 
)
inline

Defines a rotator by the given quaternion values.

◆ rotator() [5/8]

rotator ( const vec3 from,
const vec3 to 
)
inline

Defines the rotation which transforms normalized vectors `from' to `to' rotating about their cross product.

Here is the call graph for this function:

◆ rotator() [6/8]

rotator ( real  yaw,
real  pitch,
real  roll 
)
inline

Defines a rotation from Euler angles: yaw = Z-axis rotation, pitch = X-axis rotation, roll = Y-axis rotation.

◆ rotator() [7/8]

rotator ( real  m00,
real  m01,
real  m02,
real  m10,
real  m11,
real  m12,
real  m20,
real  m21,
real  m22 
)
inline

Defines a rotation from the significant 3x3 components of a 4x4 rotation matrix.

◆ rotator() [8/8]

rotator ( vec3  row1,
vec3  col1,
vec3  row2,
vec3  col2 
)
inline

Defines a rotation to transform a plane defined with row/column vectors (row2,col2) to plane (row1,col1).

This implies a rotation between plane normals and a rotation to transform the right-facing vector to the row vector. All args are assumed normalized.

Here is the call graph for this function:

Member Function Documentation

◆ conjugate()

rotator conjugate ( ) const
inline
Here is the call graph for this function:

◆ dot()

real dot ( const rotator r) const
inline

◆ getPitch()

real getPitch ( ) const
inline

Get the pitch angle (x-axis rotation in radians)

◆ getRoll()

real getRoll ( ) const
inline

Get the roll angle (y-axis rotation in radians)

◆ getYaw()

real getYaw ( ) const
inline

Get the yaw angle (z-axis rotation in radians)

◆ hash()

i32 hash ( ) const
inline

◆ interpolate()

rotator interpolate ( real  val,
const rotator r 
) const
inline

Semi-linearly interpolates between `this' and `r', this varies from a circular interpolation but is faster.

Here is the call graph for this function:

◆ inverse()

rotator inverse ( ) const
inline

Returns a rotator representing the opposite rotation.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ len()

real len ( ) const
inline

◆ norm()

rotator norm ( ) const
inline
Here is the call graph for this function:

◆ normThis()

void normThis ( )
inline
Here is the caller graph for this function:

◆ operator!=()

bool operator!= ( const rotator v) const
inline

◆ operator*() [1/3]

vec3 operator* ( const vec3 v) const
inline

Rotate `v' according to this rotator's parameters.

Here is the call graph for this function:

◆ operator*() [2/3]

rotator operator* ( const rotator r) const
inline

Returns a rotator representing the rotation `r' followed by `this'.

Here is the call graph for this function:

◆ operator*() [3/3]

rotator operator* ( real  r) const
inline
Here is the call graph for this function:

◆ operator+()

rotator operator+ ( const rotator r) const
inline
Here is the call graph for this function:

◆ operator-() [1/2]

rotator operator- ( const rotator r) const
inline
Here is the call graph for this function:

◆ operator-() [2/2]

rotator operator- ( ) const
inline
Here is the call graph for this function:

◆ operator/()

vec3 operator/ ( const vec3 v) const
inline

◆ operator==()

bool operator== ( const rotator v) const
inline
Here is the call graph for this function:

◆ set() [1/3]

void set ( const rotator r)
inline

Copy the values of `r' into `this'.

Here is the caller graph for this function:

◆ set() [2/3]

void set ( real  ry,
real  rz,
real  rw 
)
inline

sets parameters given the normalized quaternion components

◆ set() [3/3]

void set ( real  rx,
real  ry,
real  rz,
real  rw 
)
inline

Sets all parameters to those provided.

◆ setAxis()

void setAxis ( const vec3 axis,
real  rads 
)
inline

Set the rotator to represent a rotation of `rads' radians around `axis'.

Here is the call graph for this function:

◆ toMatrix() [1/2]

void toMatrix ( real mat) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ toMatrix() [2/2]

mat4 toMatrix ( ) const
inline
Here is the call graph for this function:

◆ w()

real w ( ) const
inline
Here is the caller graph for this function:

◆ x()

real x ( ) const
inline
Here is the caller graph for this function:

◆ y()

real y ( ) const
inline
Here is the caller graph for this function:

◆ z()

real z ( ) const
inline
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator*

vec3 operator* ( const vec3 v,
const rotator r 
)
friend

Commutative version of the above.

◆ operator/

vec3 operator/ ( const vec3 v,
const rotator r 
)
friend

Commutative version of the above.

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const rotator r 
)
friend

Member Data Documentation

◆ _w

real _w
protected

◆ _x

real _x
protected

◆ _y

real _y
protected

◆ _z

real _z
protected

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