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:

Inheritance graph
[legend]
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.
void LookAt (const csVector3 &v, const csVector3 &up)
 Let this transform look at the given (x,y,z) point, using up as the up-vector.
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.
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.
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 344 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 353 of file transfrm.h.

csReversibleTransform::csReversibleTransform (  )  [inline]

Initialize with the identity transformation.

Definition at line 360 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 369 of file transfrm.h.

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

Initialize with the given transformation.

Definition at line 375 of file transfrm.h.

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

Initialize with the given transformation.

Definition at line 381 of file transfrm.h.

References m_t2o.


Member Function Documentation

csReversibleTransform csReversibleTransform::GetInverse (  )  const [inline]

Get the inverse of this transform.

Definition at line 399 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 388 of file transfrm.h.

csVector3 csReversibleTransform::GetT2OTranslation (  )  const [inline]

Get 'this' to 'other' translation.

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

Definition at line 394 of file transfrm.h.

void 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)).

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 486 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 495 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 tranform, 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 406 of file transfrm.h.

References csMatrix3::GetInverse().

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 414 of file transfrm.h.

References csMatrix3::GetInverse().

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 422 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 430 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)).

Reimplemented from csTransform.

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 574 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 553 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))).

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 348 of file transfrm.h.

Referenced by csReversibleTransform(), csOrthoTransform::SetO2T(), and csOrthoTransform::SetT2O().


The documentation for this class was generated from the following file:
Generated for Crystal Space by doxygen 1.4.7