A 3D linear transform from TRS components (translation, rotation, and scale/skew)
More...
|
| Transform_ () |
| Init to identity. More...
|
|
| Transform_ (const Vec3 &trans, const Quat &rot=Quat::identity, const Vec3 &scale=Vec3::one, const Quat &skew=Quat::identity) |
| Construct from TRS components. More...
|
|
| Transform_ (const Matrix4 &mat) |
| Construct from matrix. Matrix will be decomposed, an expensive operation. More...
|
|
| ~Transform_ () |
|
Transform_ & | fromIdentity () |
| Init to identity. More...
|
|
Transform_ & | fromTrs (const Vec3 &trans, const Quat &rot=Quat::identity, const Vec3 &scale=Vec3::one, const Quat &skew=Quat::identity) |
| Init from TRS components. More...
|
|
Transform_ & | fromMatrix (const Matrix4 &mat) |
| Init from matrix. Matrix will be decomposed, an expensive operation. More...
|
|
Transform_ & | operator= (const Transform_ &rhs) |
|
Transform_ | operator* (const Transform_ &tm) const |
|
Vec3 | operator* (const Vec3 &v) const |
|
Vec4 | operator* (const Vec4 &v) const |
|
Vec2 | operator* (const Vec2 &v) const |
|
Transform_ & | operator*= (const Transform_ &tm) |
|
Vec3 | mulRotScale (const Vec3 &v) const |
| Transform by just rotation and scale/skew components (no translation) More...
|
|
bool | operator== (const Transform_ &rhs) const |
|
bool | operator!= (const Transform_ &rhs) const |
|
Transform_ | inverse () const |
|
void | resetTrans () |
|
void | resetRot () |
|
void | resetScale () |
|
void | setTrans (const Vec3 &trans) |
|
const Vec3 & | getTrans () const |
|
void | setRot (const Quat &rot) |
|
const Quat & | getRot () const |
|
void | setScale (const Vec3 &scale, const Quat &skew=Quat::identity) |
|
void | setScale (Real f) |
|
const Vec3 & | getScale () const |
|
const Quat & | getSkew () const |
|
void | getTrs (optional< Vec3 & > trans=optnull, optional< Quat & > rot=optnull, optional< Vec3 & > scale=optnull, optional< Quat & > skew=optnull) const |
|
Transform_ & | translate (const Vec3 &v) |
| Make a tm that performs this transform first, then does a translation. ie. T * this. More...
|
|
Transform_ & | preTranslate (const Vec3 &v) |
| Make a tm that does a translation first, then performs this transform. ie. this * T. More...
|
|
Transform_ & | rotate (const Quat &q) |
| Make a tm that performs this transform first, then does a rotation. ie. R * this. More...
|
|
Transform_ & | preRotate (const Quat &q) |
| Make a tm that does a rotation first, then performs this transform. ie. this * R. More...
|
|
Transform_ & | scale (const Vec3 &v, const Quat &skew=Quat::identity) |
| Make a tm that performs this transform first, then does a scale. ie. S * this. More...
|
|
Transform_ & | scale (Real f) |
| Uniform scale. More...
|
|
Transform_ & | preScale (const Vec3 &v, const Quat &skew=Quat::identity) |
| Make a tm that does a scale first, then performs this transform. ie. this * S. More...
|
|
Transform_ & | preScale (Real f) |
| Uniform prescale. More...
|
|
bool | isIdentity () const |
|
bool | hasTrans () const |
|
bool | hasRot () const |
|
bool | hasScale () const |
|
bool | hasUniformScale () const |
|
bool | hasSkew () const |
|
template<class Real>
class honey::Transform_< Real >
A 3D linear transform from TRS components (translation, rotation, and scale/skew)
The TRS model is equivalent to a 4x4 affine homogeneous matrix where translation occupies the last column, and rotation combines with scale/skew to form a 3x3 sub-matrix in the upper-left:
| RS RS RS Tx | T: Translation
| RS RS RS Ty | R: Rotation
| RS RS RS Tz | S: Scale/Skew
| 0 0 0 1 |
-> A transform first scales (S), then rotates (R), then translates (T).
-> Scaling is done by first rotating into scale-space using the inverse of skew ( ) then scaling (K), then rotating back out of scale-space (U).
Advantages of TRS model over affine matrix model:
- Rotation, scale and skew can be accessed independently and immediately
- Quats can be used directly for rotation and skew (don't need to convert to 3x3 rot matrix)
- Faster than matrices at forward and inverse transform ops (unless matrices have hardware acceleration)
Disadvantages:
- Can't concatenate skews
- Can't represent projective transforms (ie. where last row in matrix is not identity)
Be wary of the following operations:
- A*B where A has non-uniform scale and B has rotation -> returns transform with skew
- A.inverse() where A has non-uniform scale and rotation -> returns transform with skew
- A*B where A and B both have non-uniform scale and B has rotation -> error
- A*B where A and B both have non-uniform scale and either has skew -> error
- A*B where A and B both have skew -> error