CrystalSpace

Public API Reference

csReversibleTransform Class Reference
[Geometry utilities]

A class which defines a reversible transformation from one coordinate system to another by maintaining an inverse transformation matrix. More...

#include <csgeom/transfrm.h>

Inheritance diagram for csReversibleTransform:

List of all members.

Public Member Functions

 csReversibleTransform (const csReversibleTransform &t)
 Initialize with the given transformation.
 csReversibleTransform (const csTransform &t)
 Initialize with the given transformation.
 csReversibleTransform (const csMatrix3 &o2t, const csVector3 &pos)
 Initialize with the given transformation.
 csReversibleTransform ()
 Initialize with the identity transformation.
csReversibleTransform GetInverse () const
 Get the inverse of this transform.
const csMatrix3GetT2O () const
 Get 'this' to 'other' transformation matrix.
csVector3 GetT2OTranslation () const
 Get 'this' to 'other' translation.
bool LookAt (const csVector3 &v, const csVector3 &up)
 Let this transform look at the given (x,y,z) point, using up as the up-vector.
bool LookAtXUpY (const csVector3 &v, const csVector3 &up)
 Let the X vector of this transform look into a given direction with the Y vector of this transform as the 'up' orientation.
bool LookAtXUpZ (const csVector3 &v, const csVector3 &up)
 Let the X vector of this transform look into a given direction with the Z vector of this transform as the 'up' orientation.
bool LookAtYUpX (const csVector3 &v, const csVector3 &up)
 Let the Y vector of this transform look into a given direction with the X vector of this transform as the 'up' orientation.
bool LookAtYUpZ (const csVector3 &v, const csVector3 &up)
 Let the Y vector of this transform look into a given direction with the Z vector of this transform as the 'up' orientation.
bool LookAtZUpX (const csVector3 &v, const csVector3 &up)
 Let the Z vector of this transform look into a given direction with the X vector of this transform as the 'up' orientation.
bool LookAtZUpY (const csVector3 &v, const csVector3 &up)
 Let the Z vector of this transform look into a given direction with the Y vector of this transform as the 'up' orientation.
void RotateOther (const csMatrix3 &m)
 Use the given transformation matrix, in other space, to reorient the transformation.
void RotateOther (const csVector3 &v, float angle)
 Rotate the transform by the angle (radians) around the given vector, in other coordinates.
void RotateThis (const csMatrix3 &m)
 Use the given transformation matrix, in this space, to reorient the transformation.
void RotateThis (const csVector3 &v, float angle)
 Rotate the transform by the angle (radians) around the given vector, in these coordinates.
virtual void SetO2T (const csMatrix3 &m)
 Set 'other' to 'this' transformation matrix.
virtual void SetT2O (const csMatrix3 &m)
 Set 'this' to 'other' transformation matrix.
csBox3 This2Other (const csBox3 &box) const
 Converts a box in 'this' space to 'other' space.
csSphere This2Other (const csSphere &s) const
 Convert a sphere in 'this' space to 'other' space.
void This2Other (const csPlane3 &p, const csVector3 &point, csPlane3 &result) const
 Convert a plane in 'this' space to 'other' space.
csPlane3 This2Other (const csPlane3 &p) const
 Convert a plane in 'this' space to 'other' space.
csVector3 This2Other (const csVector3 &v) const
 Convert vector v in 'this' space to 'other' space.
csPlane3 This2OtherRelative (const csPlane3 &p) const
 Convert a plane in 'this' space to 'other' space.
csVector3 This2OtherRelative (const csVector3 &v) const
 Convert vector v in 'this' space to a vector in 'other' space, relative to local origin.

Protected Member Functions

 csReversibleTransform (const csMatrix3 &o2t, const csMatrix3 &t2o, const csVector3 &pos)
 Initialize transform with both transform matrix and inverse tranform.

Protected Attributes

csMatrix3 m_t2o
 Inverse transformation matrix ('this' to 'other' space).

Friends

csTransform operator* (const csTransform &t1, const csReversibleTransform &t2)
 Combine two transforms, rightmost first.
csReversibleTransform operator* (const csReversibleTransform &t1, const csReversibleTransform &t2)
 Combine two transforms, rightmost first.
csReversibleTransformoperator*= (csReversibleTransform &t1, const csReversibleTransform &t2)
 Combine two transforms, rightmost first.
csReversibleTransform operator/ (const csReversibleTransform &t1, const csReversibleTransform &t2)
 Combine two transforms, reversing t2 then applying t1.
csBox3 operator/ (const csBox3 &p, const csReversibleTransform &t)
 Reverse a transformation on a box.
csSphere operator/ (const csSphere &p, const csReversibleTransform &t)
 Reverse a transformation on a sphere.
csPlane3 operator/ (const csPlane3 &p, const csReversibleTransform &t)
 Reverse a transformation on a Plane.
csVector3 operator/ (const csVector3 &v, const csReversibleTransform &t)
 Reverse a transformation on a 3D vector.
csReversibleTransformoperator/= (csReversibleTransform &t1, const csReversibleTransform &t2)
 Combine two transforms, reversing t2 then applying t1.
csPlane3operator/= (csPlane3 &p, const csReversibleTransform &t)
 Reverse a transformation on a Plane.
csVector3operator/= (csVector3 &v, const csReversibleTransform &t)
 Reverse a transformation on a 3D vector.

Detailed Description

A class which defines a reversible transformation from one coordinate system to another by maintaining an inverse transformation matrix.

This version is similar to csTransform (in fact, it is a sub-class) but it is more efficient if you plan to do inverse transformations often.

Remarks:
Despite that the superclass csTransform transforms from 'other' to 'this' space, commonly csReversibleTransform instances are named like 'this2other' - e.g. 'object2world' where 'this' space is object space and 'other' space is world space.

Definition at line 392 of file transfrm.h.


Constructor & Destructor Documentation

csReversibleTransform::csReversibleTransform ( const csMatrix3 o2t,
const csMatrix3 t2o,
const csVector3 pos 
) [inline, protected]

Initialize transform with both transform matrix and inverse tranform.

Definition at line 401 of file transfrm.h.

csReversibleTransform::csReversibleTransform (  )  [inline]

Initialize with the identity transformation.

Definition at line 412 of file transfrm.h.

csReversibleTransform::csReversibleTransform ( const csMatrix3 o2t,
const csVector3 pos 
) [inline]

Initialize with the given transformation.

The transformation is given as a 3x3 matrix and a vector. The transformation is defined to mean T=M*(O-V) with T the vector in 'this' space, O the vector in 'other' space, M the transformation matrix and V the transformation vector.

Definition at line 421 of file transfrm.h.

csReversibleTransform::csReversibleTransform ( const csTransform t  )  [inline]

Initialize with the given transformation.

Definition at line 427 of file transfrm.h.

csReversibleTransform::csReversibleTransform ( const csReversibleTransform t  )  [inline]

Initialize with the given transformation.

Definition at line 433 of file transfrm.h.


Member Function Documentation

csReversibleTransform csReversibleTransform::GetInverse (  )  const [inline]

Get the inverse of this transform.

Definition at line 451 of file transfrm.h.

const csMatrix3& csReversibleTransform::GetT2O (  )  const [inline]

Get 'this' to 'other' transformation matrix.

This corresponds to the inverse of M.

Definition at line 440 of file transfrm.h.

csVector3 csReversibleTransform::GetT2OTranslation (  )  const [inline]

Get 'this' to 'other' translation.

This will calculate and return -(M*V).

Definition at line 446 of file transfrm.h.

bool csReversibleTransform::LookAt ( const csVector3 v,
const csVector3 up 
)

Let this transform look at the given (x,y,z) point, using up as the up-vector.

'v' should be given relative to the position of the origin of this transform. For example, if the transform is located at pos=(3,1,9) and you want it to look at location loc=(10,2,8) while keeping the orientation so that the up-vector is upwards then you can use: LookAt (loc-pos, csVector3 (0, 1, 0)).

Returns false if the lookat couldn't be calculated for some reason. In that case the transform will be reset to identity.

This function is equivalent to LookAtZUpY() except that the latter will not modify the transform if the lookat calculation fails.

bool csReversibleTransform::LookAtXUpY ( const csVector3 v,
const csVector3 up 
)

Let the X vector of this transform look into a given direction with the Y vector of this transform as the 'up' orientation.

This function will not modify the transform if it returns false.

bool csReversibleTransform::LookAtXUpZ ( const csVector3 v,
const csVector3 up 
)

Let the X vector of this transform look into a given direction with the Z vector of this transform as the 'up' orientation.

This function will not modify the transform if it returns false.

bool csReversibleTransform::LookAtYUpX ( const csVector3 v,
const csVector3 up 
)

Let the Y vector of this transform look into a given direction with the X vector of this transform as the 'up' orientation.

This function will not modify the transform if it returns false.

bool csReversibleTransform::LookAtYUpZ ( const csVector3 v,
const csVector3 up 
)

Let the Y vector of this transform look into a given direction with the Z vector of this transform as the 'up' orientation.

This function will not modify the transform if it returns false.

bool csReversibleTransform::LookAtZUpX ( const csVector3 v,
const csVector3 up 
)

Let the Z vector of this transform look into a given direction with the X vector of this transform as the 'up' orientation.

This function will not modify the transform if it returns false.

bool csReversibleTransform::LookAtZUpY ( const csVector3 v,
const csVector3 up 
)

Let the Z vector of this transform look into a given direction with the Y vector of this transform as the 'up' orientation.

This function will not modify the transform if it returns false.

void csReversibleTransform::RotateOther ( const csMatrix3 m  )  [inline]

Use the given transformation matrix, in other space, to reorient the transformation.

Note: this function rotates the transformation, not the coordinate system. This basically calculates Minv=m*Minv (with Minv the inverse of M). M will be calculated accordingly.

Definition at line 543 of file transfrm.h.

void csReversibleTransform::RotateOther ( const csVector3 v,
float  angle 
)

Rotate the transform by the angle (radians) around the given vector, in other coordinates.

Note: this function rotates the transform, not the coordinate system.

void csReversibleTransform::RotateThis ( const csMatrix3 m  )  [inline]

Use the given transformation matrix, in this space, to reorient the transformation.

Note: this function rotates the transformation, not the coordinate system. This basically calculates Minv=Minv*m (with Minv the inverse of M). M will be calculated accordingly.

Definition at line 552 of file transfrm.h.

void csReversibleTransform::RotateThis ( const csVector3 v,
float  angle 
)

Rotate the transform by the angle (radians) around the given vector, in these coordinates.

Note: this function rotates the transform, not the coordinate system.

virtual void csReversibleTransform::SetO2T ( const csMatrix3 m  )  [inline, virtual]

Set 'other' to 'this' transformation matrix.

This is the 3x3 matrix M from the transform equation T=M*(O-V).

Reimplemented from csTransform.

Reimplemented in csOrthoTransform.

Definition at line 458 of file transfrm.h.

virtual void csReversibleTransform::SetT2O ( const csMatrix3 m  )  [inline, virtual]

Set 'this' to 'other' transformation matrix.

This is equivalent to SetO2T() except that you can now give the inverse matrix.

Reimplemented in csOrthoTransform.

Definition at line 466 of file transfrm.h.

csBox3 csReversibleTransform::This2Other ( const csBox3 box  )  const

Converts a box in 'this' space to 'other' space.

csSphere csReversibleTransform::This2Other ( const csSphere s  )  const

Convert a sphere in 'this' space to 'other' space.

void csReversibleTransform::This2Other ( const csPlane3 p,
const csVector3 point,
csPlane3 result 
) const

Convert a plane in 'this' space to 'other' space.

This is an optimized version for which a point on the new plane is known (point). The result is stored in 'result'. If 'p' is expressed as (N,D) (with N a vector for the A,B,C components of 'p') then this will return a new plane which looks like (Minv*N,-(Minv*N)*point) (with Minv the inverse of M).

csPlane3 csReversibleTransform::This2Other ( const csPlane3 p  )  const

Convert a plane in 'this' space to 'other' space.

If 'p' is expressed as (N,D) (with N a vector for the A,B,C components of 'p') then this will return a new plane which looks like (Minv*N,D-N*(M*V)) (with Minv the inverse of M).

csVector3 csReversibleTransform::This2Other ( const csVector3 v  )  const [inline]

Convert vector v in 'this' space to 'other' space.

This is the basic inverse transform operation and it corresponds with the calculation of V+Minv*v (with Minv the inverse of M).

Definition at line 474 of file transfrm.h.

csPlane3 csReversibleTransform::This2OtherRelative ( const csPlane3 p  )  const

Convert a plane in 'this' space to 'other' space.

This version ignores translation. If 'p' is expressed as (N,D) (with N a vector for the A,B,C components of 'p') then this will return a new plane which looks like (Minv*N,D) (with Minv the inverse of M).

csVector3 csReversibleTransform::This2OtherRelative ( const csVector3 v  )  const [inline]

Convert vector v in 'this' space to a vector in 'other' space, relative to local origin.

This calculates and returns Minv*v (with Minv the inverse of M).

Definition at line 482 of file transfrm.h.


Friends And Related Function Documentation

csTransform operator* ( const csTransform t1,
const csReversibleTransform t2 
) [friend]

Combine two transforms, rightmost first.

Given the following definitions:

  • 't1' expressed as T=t1.M*(O-t1.V)
  • 't2' expressed as T=t2.M*(O-t2.V)
  • t1.Minv is the inverse of t1.M
  • t2.Minv is the inverse of t2.M

Then this will calculate a new transformation in 't1' as follows: T=(t1.M*t2.M)*(O-(t2.Minv*t1.V+t2.V)).

csReversibleTransform operator* ( const csReversibleTransform t1,
const csReversibleTransform t2 
) [friend]

Combine two transforms, rightmost first.

Given the following definitions:

  • 't1' expressed as T=t1.M*(O-t1.V)
  • 't2' expressed as T=t2.M*(O-t2.V)
  • t1.Minv is the inverse of t1.M
  • t2.Minv is the inverse of t2.M

Then this will calculate a new transformation in 't1' as follows: T=(t1.M*t2.M)*(O-(t2.Minv*t1.V+t2.V)).

Definition at line 681 of file transfrm.h.

csReversibleTransform& operator*= ( csReversibleTransform t1,
const csReversibleTransform t2 
) [friend]

Combine two transforms, rightmost first.

Given the following definitions:

  • 't1' expressed as T=t1.M*(O-t1.V)
  • 't2' expressed as T=t2.M*(O-t2.V)
  • t1.Minv is the inverse of t1.M
  • t2.Minv is the inverse of t2.M

Then this will calculate a new transformation in 't1' as follows: T=(t1.M*t2.M)*(O-(t2.Minv*t1.V+t2.V)).

Definition at line 660 of file transfrm.h.

csReversibleTransform operator/ ( const csReversibleTransform t1,
const csReversibleTransform t2 
) [friend]

Combine two transforms, reversing t2 then applying t1.

Given the following definitions:

  • 't1' expressed as T=t1.M*(O-t1.V)
  • 't2' expressed as T=t2.M*(O-t2.V)
  • t1.Minv is the inverse of t1.M
  • t2.Minv is the inverse of t2.M

Then this will calculate a new transformation in 't1' as follows: T=(t1.M*t2.Minv)*(O-(t2.M*(t1.V-t2.V))).

csBox3 operator/ ( const csBox3 p,
const csReversibleTransform t 
) [friend]

Reverse a transformation on a box.

This corresponds exactly to calling t.This2Other(p).

csSphere operator/ ( const csSphere p,
const csReversibleTransform t 
) [friend]

Reverse a transformation on a sphere.

This corresponds exactly to calling t.This2Other(p).

csPlane3 operator/ ( const csPlane3 p,
const csReversibleTransform t 
) [friend]

Reverse a transformation on a Plane.

This corresponds exactly to calling t.This2Other(p).

csVector3 operator/ ( const csVector3 v,
const csReversibleTransform t 
) [friend]

Reverse a transformation on a 3D vector.

This corresponds exactly to calling t.This2Other(v).

csReversibleTransform& operator/= ( csReversibleTransform t1,
const csReversibleTransform t2 
) [friend]

Combine two transforms, reversing t2 then applying t1.

Given the following definitions:

  • 't1' expressed as T=t1.M*(O-t1.V)
  • 't2' expressed as T=t2.M*(O-t2.V)
  • t1.Minv is the inverse of t1.M
  • t2.Minv is the inverse of t2.M

Then this will calculate a new transformation in 't1' as follows: T=(t1.M*t2.Minv)*(O-(t2.M*(t1.V-t2.V))).

csPlane3& operator/= ( csPlane3 p,
const csReversibleTransform t 
) [friend]

Reverse a transformation on a Plane.

This corresponds exactly to calling p = t.This2Other(p).

csVector3& operator/= ( csVector3 v,
const csReversibleTransform t 
) [friend]

Reverse a transformation on a 3D vector.

This corresponds exactly to calling v=t.This2Other(v).


Member Data Documentation

Inverse transformation matrix ('this' to 'other' space).

Definition at line 396 of file transfrm.h.


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

Generated for Crystal Space 2.0 by doxygen 1.6.1