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

#include <RenderTypes.h>

Collaboration diagram for transform:
Collaboration graph

Public Member Functions

 transform (const vec3 &trans=vec3(), const vec3 &scale=vec3(1.0), const rotator &rot=rotator(), bool isInv=false)
 Define a transform with translation and scale vectors and a rotator, default values define the identity transform. More...
 
 transform (const transform &t)
 
 transform (real x, real y, real z, real sx, real sy, real sz, real yaw, real pitch, real roll, bool isInv=false)
 Define a transform with translation, scale, and Euler angle values. More...
 
vec3 getTranslation () const
 
vec3 getScale () const
 
rotator getRotation () const
 
bool isInverse () const
 
void setTranslation (const vec3 &v)
 
void setScale (const vec3 &v)
 
void setRotation (const rotator &r)
 
vec3 operator* (const vec3 &v) const
 Transforms `v' by scaling->rotating->translating if not an inverse transform, otherwise by translating->rotating->scaling. More...
 
vec3 operator/ (const vec3 &v) const
 Transform `v' by the inverse of `this'. More...
 
Ray operator* (const Ray &r) const
 Transforms `r' by transforming its position by `this' but it direction by the directional components only of `this'. More...
 
transform operator* (const transform &t) const
 
bool operator== (const transform &t) const
 
transform inverse () const
 Get the inverse transform of `this', ie. for any transform t and vec3 v (t.inverse()*(t*v)) is a no-op. More...
 
transform directional () const
 Get the directional version of this transform which is suitable for transforming directional vectors correctly, ie. no translation component. More...
 
void toMatrix (real *mat) const
 Fill in the 4x4 matrix representing this transform. This assumes `mat' has length 16. More...
 
mat4 toMatrix () const
 

Public Attributes

vec3 trans
 
vec3 scale
 
rotator rot
 
bool _isInverse
 

Friends

vec3 operator* (const vec3 &v, const transform &t)
 Commutative version of the above. More...
 
vec3 operator/ (const vec3 &v, const transform &t)
 Commutative version of the above. More...
 
vec3operator*= (vec3 &v, const transform &t)
 
Ray operator* (const Ray &r, const transform &t)
 Commutative version of the above. More...
 
std::ostream & operator<< (std::ostream &out, const transform &t)
 

Detailed Description

Represents the combination of translation, scale, and rotation operations. When multiplying a vector v by a transform t, the order of operations is to scale, rotate, then translate. If isInverse() is true then the order is reversed. This type doesn't allow arbitrary operation orders or other transforms like shear thus isn't as general as a 4x4 matrix. The advantage is that the translation, scale, and rotation components are defined separately and can be accessed or modified independently. A transform has an matrix equivalent, transforms can thus be compounded through matrix multiplication.

Constructor & Destructor Documentation

◆ transform() [1/3]

transform ( const vec3 trans = vec3(),
const vec3 scale = vec3(1.0),
const rotator rot = rotator(),
bool  isInv = false 
)
inline

Define a transform with translation and scale vectors and a rotator, default values define the identity transform.

◆ transform() [2/3]

transform ( const transform t)
inline

◆ transform() [3/3]

transform ( real  x,
real  y,
real  z,
real  sx,
real  sy,
real  sz,
real  yaw,
real  pitch,
real  roll,
bool  isInv = false 
)
inline

Define a transform with translation, scale, and Euler angle values.

Member Function Documentation

◆ directional()

transform directional ( ) const
inline

Get the directional version of this transform which is suitable for transforming directional vectors correctly, ie. no translation component.

Here is the caller graph for this function:

◆ getRotation()

rotator getRotation ( ) const
inline

◆ getScale()

vec3 getScale ( ) const
inline

◆ getTranslation()

vec3 getTranslation ( ) const
inline

◆ inverse()

transform inverse ( ) const
inline

Get the inverse transform of `this', ie. for any transform t and vec3 v (t.inverse()*(t*v)) is a no-op.

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

◆ isInverse()

bool isInverse ( ) const
inline

◆ operator*() [1/3]

vec3 operator* ( const vec3 v) const
inline

Transforms `v' by scaling->rotating->translating if not an inverse transform, otherwise by translating->rotating->scaling.

◆ operator*() [2/3]

Ray operator* ( const Ray r) const
inline

Transforms `r' by transforming its position by `this' but it direction by the directional components only of `this'.

Here is the call graph for this function:

◆ operator*() [3/3]

transform operator* ( const transform t) const
inline

Calculate the transform representing the application of `t' followed by `this'. This transform isn't always equivalent to applying `t' to an object followed by `this'. If a combination of rotation and scaling values in `t' or `this' results skew then the transform produced by this operator will scale and rotate in unexpected ways. Skew is the result of applying affine operations in an order which produces a non-affine total result.

This method operates by producing a transform whose position that of `t' plus that of `this' transformed by the directional components of `t', with a scale and rotation values which are the products of those from `t' and `this'.

◆ operator/()

vec3 operator/ ( const vec3 v) const
inline

Transform `v' by the inverse of `this'.

◆ operator==()

bool operator== ( const transform t) const
inline

◆ setRotation()

void setRotation ( const rotator r)
inline
Here is the caller graph for this function:

◆ setScale()

void setScale ( const vec3 v)
inline
Here is the caller graph for this function:

◆ setTranslation()

void setTranslation ( const vec3 v)
inline

◆ toMatrix() [1/2]

void toMatrix ( real mat) const
inline

Fill in the 4x4 matrix representing this transform. This assumes `mat' has length 16.

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:

Friends And Related Function Documentation

◆ operator* [1/2]

vec3 operator* ( const vec3 v,
const transform t 
)
friend

Commutative version of the above.

◆ operator* [2/2]

Ray operator* ( const Ray r,
const transform t 
)
friend

Commutative version of the above.

◆ operator*=

vec3& operator*= ( vec3 v,
const transform t 
)
friend

◆ operator/

vec3 operator/ ( const vec3 v,
const transform t 
)
friend

Commutative version of the above.

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const transform t 
)
friend

Member Data Documentation

◆ _isInverse

bool _isInverse

◆ rot

rotator rot

◆ scale

vec3 scale

◆ trans

vec3 trans

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