CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

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 <transfrm.h>

Inheritance diagram for csReversibleTransform:

csTransform csOrthoTransform csCamera List of all members.

Public Methods

 csReversibleTransform ()
 Initialize with the identity transformation. More...

 csReversibleTransform (const csMatrix3 &o2t, const csVector3 &pos)
 Initialize with the given transformation. More...

 csReversibleTransform (const csTransform &t)
 Initialize with the given transformation. More...

 csReversibleTransform (const csReversibleTransform &t)
 Initialize with the given transformation. More...

const csMatrix3GetT2O () const
 Get 'this' to 'other' transformation matrix. More...

csVector3 GetT2OTranslation () const
 Get 'this' to 'other' translation. More...

csReversibleTransform GetInverse () const
 Get the inverse of this transform. More...

virtual void SetO2T (const csMatrix3 &m)
 Set 'other' to 'this' transformation matrix. More...

virtual void SetT2O (const csMatrix3 &m)
 Set 'this' to 'other' transformation matrix. More...

csVector3 This2Other (const csVector3 &v) const
 Convert vector v in 'this' space to 'other' space. More...

csVector3 This2OtherRelative (const csVector3 &v) const
 Convert vector v in 'this' space to a vector in 'other' space, relative to local origin. More...

csPlane3 This2Other (const csPlane3 &p) const
 Convert a plane in 'this' space to 'other' space. More...

csPlane3 This2OtherRelative (const csPlane3 &p) const
 Convert a plane in 'this' space to 'other' space. More...

void This2Other (const csPlane3 &p, const csVector3 &point, csPlane3 &result) const
 Convert a plane in 'this' space to 'other' space. More...

csSphere This2Other (const csSphere &s) const
 Convert a sphere in 'this' space to 'other' space. More...

void RotateOther (const csVector3 &v, float angle)
 Rotate the transform by the angle (radians) around the given vector, in other coordinates. More...

void RotateThis (const csVector3 &v, float angle)
 Rotate the transform by the angle (radians) around the given vector, in these coordinates. More...

void RotateOther (const csMatrix3 &m)
 Use the given transformation matrix, in other space, to reorient the transformation. More...

void RotateThis (const csMatrix3 &m)
 Use the given transformation matrix, in this space, to reorient the transformation. More...

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. More...


Protected Methods

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


Protected Attributes

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


Friends

csVector3 operator/ (const csVector3 &v, const csReversibleTransform &t)
 Reverse a transformation on a 3D vector. More...

csVector3operator/= (csVector3 &v, const csReversibleTransform &t)
 Reverse a transformation on a 3D vector. More...

csPlane3 operator/ (const csPlane3 &p, const csReversibleTransform &t)
 Reverse a transformation on a Plane. More...

csPlane3operator/= (csPlane3 &p, const csReversibleTransform &t)
 Reverse a transformation on a Plane. More...

csSphere operator/ (const csSphere &p, const csReversibleTransform &t)
 Reverse a transformation on a sphere. More...

csReversibleTransform & operator *= (csReversibleTransform &t1, const csReversibleTransform &t2)
 Combine two transforms, rightmost first. More...

csReversibleTransform operator * (const csReversibleTransform &t1, const csReversibleTransform &t2)
 Combine two transforms, rightmost first. More...

csTransform operator * (const csTransform &t1, const csReversibleTransform &t2)
 Combine two transforms, rightmost first. More...

csReversibleTransform & operator/= (csReversibleTransform &t1, const csReversibleTransform &t2)
 Combine two transforms, reversing t2 then applying t1. More...

csReversibleTransform operator/ (const csReversibleTransform &t1, const csReversibleTransform &t2)
 Combine two transforms, reversing t2 then applying t1. More...


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.

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

csReversibleTransform::csReversibleTransform   [inline]
 

Initialize with the identity transformation.

Definition at line 305 of file transfrm.h.

Referenced by GetInverse.

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

References csMatrix3::GetInverse, and csTransform::m_o2t.

csReversibleTransform::csReversibleTransform const csTransform   t [inline]
 

Initialize with the given transformation.

Definition at line 320 of file transfrm.h.

References csMatrix3::GetInverse, and csTransform::m_o2t.

csReversibleTransform::csReversibleTransform const csReversibleTransform &    t [inline]
 

Initialize with the given transformation.

Definition at line 326 of file transfrm.h.


Member Function Documentation

csReversibleTransform csReversibleTransform::GetInverse   const [inline]
 

Get the inverse of this transform.

Definition at line 344 of file transfrm.h.

References csReversibleTransform, csTransform::m_o2t, and csTransform::v_o2t.

const csMatrix3& csReversibleTransform::GetT2O   const [inline]
 

Get 'this' to 'other' transformation matrix.

This corresponds to the inverse of M.

Definition at line 333 of file transfrm.h.

Referenced by csCamera::GetC2W.

csVector3 csReversibleTransform::GetT2OTranslation   const [inline]
 

Get 'this' to 'other' translation.

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

Definition at line 339 of file transfrm.h.

References csTransform::m_o2t, and csTransform::v_o2t.

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

References SetT2O.

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

References SetT2O.

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 csCamera.

Definition at line 351 of file transfrm.h.

References csMatrix3::GetInverse, and csTransform::m_o2t.

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 csCamera.

Definition at line 359 of file transfrm.h.

References csMatrix3::GetInverse, and csTransform::m_o2t.

Referenced by RotateOther, and RotateThis.

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

References csTransform::v_o2t.

Referenced by csCamera::Camera2World.

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

Referenced by csCamera::Camera2WorldRelative.


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 517 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 495 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

csMatrix3 csReversibleTransform::m_t2o [protected]
 

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

Definition at line 293 of file transfrm.h.

Referenced by csCamera::Move, csCamera::MoveUnrestricted, csOrthoTransform::SetO2T, and csOrthoTransform::SetT2O.


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