Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
csReversibleTransform Class Reference

#include <optransfrm.h>

Inheritance diagram for csReversibleTransform:
csTransform csOrthoTransform

Public Member Functions

 csReversibleTransform ()
 
 csReversibleTransform (const Matrix &m)
 
 csReversibleTransform (const csMatrix3 &o2t, const csVector3 &pos)
 
 csReversibleTransform (const csTransform &t)
 
 csReversibleTransform (const csReversibleTransform &t)
 
const csMatrix3GetT2O () const
 
csVector3 GetT2OTranslation () const
 
csReversibleTransform GetInverse () const
 
virtual void SetO2T (const csMatrix3 &m)
 
virtual void SetT2O (const csMatrix3 &m)
 
csVector3 This2Other (const csVector3 &v) const
 
csVector3 This2OtherRelative (const csVector3 &v) const
 
void RotateOther (const csVector3 &v, float angle)
 
void RotateThis (const csVector3 &v, float angle)
 
void RotateOther (const csMatrix3 &m)
 
void RotateThis (const csMatrix3 &m)
 
void LookAt (const csVector3 &v, const csVector3 &up)
 
- Public Member Functions inherited from csTransform
 csTransform ()
 
 csTransform (const csMatrix3 &other2this, const csVector3 &origin_pos)
 
const csMatrix3GetO2T () const
 
const csVector3GetO2TTranslation () const
 
const csVector3GetOrigin () const
 
virtual void SetO2TTranslation (const csVector3 &v)
 
void SetOrigin (const csVector3 &v)
 
void Translate (const csVector3 &v)
 
csVector3 Other2This (const csVector3 &v) const
 
csVector3 Other2ThisRelative (const csVector3 &v) const
 

Protected Member Functions

 csReversibleTransform (const csMatrix3 &o2t, const csMatrix3 &t2o, const csVector3 &pos)
 

Protected Attributes

csMatrix3 m_t2o
 Inverse transformation matrix ('this' to 'other' space). More...
 
- Protected Attributes inherited from csTransform
csMatrix3 m_o2t
 Transformation matrix from 'other' space to 'this' space. More...
 
csVector3 v_o2t
 Location of the origin for 'this' 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...
 
csReversibleTransformoperator*= (csReversibleTransform &t1, const csReversibleTransform &t2)
 Reverse a transformation on a Plane. More...
 
csReversibleTransform operator* (const csReversibleTransform &t1, const csReversibleTransform &t2)
 Combine two transforms, with the rightmost being applied first. More...
 
csTransform operator* (const csTransform &t1, const csReversibleTransform &t2)
 Combine two transforms, with the rightmost being applied first. More...
 
csReversibleTransformoperator/= (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 172 of file optransfrm.h.

Constructor & Destructor Documentation

csReversibleTransform::csReversibleTransform ( const csMatrix3 o2t,
const csMatrix3 t2o,
const csVector3 pos 
)
inlineprotected

Initialize transform with both transform matrix and inverse tranform.

Definition at line 181 of file optransfrm.h.

182  : csTransform (o2t,pos), m_t2o (t2o) {}
csReversibleTransform::csReversibleTransform ( )
inline

Initialize with the identity transformation.

Definition at line 188 of file optransfrm.h.

Referenced by GetInverse().

188 : csTransform (), m_t2o () {}
csReversibleTransform::csReversibleTransform ( const Matrix m)
inline

Daniel: I think that this matrix is in row major order... but it appears to look for the matrix that takes from world to object hence it is the transpose... transpose of transpose is identty...which is what I pass in below

Definition at line 193 of file optransfrm.h.

References i, j, and k.

193  :
194  csTransform (
195  csMatrix3 (m.r[0],m.r[3],m.r[6],
196  m.r[1],m.r[4],m.r[7],
197  m.r[2],m.r[5],m.r[8]).GetInverse(),
198  csVector3 (m.p.i,m.p.j,m.p.k)),
199  m_t2o(m.r[0],m.r[3],m.r[6],
200  m.r[1],m.r[4],m.r[7],
201  m.r[2],m.r[5],m.r[8]) {
202  }
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 210 of file optransfrm.h.

References csMatrix3::GetInverse(), csTransform::m_o2t, and m_t2o.

210  :
211  csTransform (o2t,pos) { m_t2o = m_o2t.GetInverse (); }
csReversibleTransform::csReversibleTransform ( const csTransform t)
inline

Initialize with the given transformation.

Definition at line 216 of file optransfrm.h.

References csMatrix3::GetInverse(), csTransform::m_o2t, and m_t2o.

216  :
217  csTransform (t) { m_t2o = m_o2t.GetInverse (); }
csReversibleTransform::csReversibleTransform ( const csReversibleTransform t)
inline

Definition at line 219 of file optransfrm.h.

References m_t2o.

219  :
220  csTransform (t) { m_t2o = t.m_t2o; }

Member Function Documentation

csReversibleTransform csReversibleTransform::GetInverse ( ) const
inline

Get the inverse of this transform.

Definition at line 235 of file optransfrm.h.

References csReversibleTransform(), csTransform::m_o2t, m_t2o, and csTransform::v_o2t.

236  { return csReversibleTransform (m_t2o, m_o2t, -m_o2t*v_o2t); }
const csMatrix3& csReversibleTransform::GetT2O ( ) const
inline

Get 'this' to 'other' transformation matrix.

Definition at line 225 of file optransfrm.h.

References m_t2o.

Referenced by csOPCODECollider::Collide().

225 { return m_t2o; }
csVector3 csReversibleTransform::GetT2OTranslation ( ) const
inline

Get 'this' to 'other' translation.

Definition at line 230 of file optransfrm.h.

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

230 { return -m_o2t*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.

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

Convert a plane in 'this' space to 'other' space. Convert a plane in 'this' space to 'other' space. This version ignores translation. 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'. 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::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.

Definition at line 303 of file optransfrm.h.

References m_t2o, and SetT2O().

303 { SetT2O (m * m_t2o); }
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.

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.

Definition at line 310 of file optransfrm.h.

References m_t2o, and SetT2O().

310 { SetT2O (m_t2o * m); }
virtual void csReversibleTransform::SetO2T ( const csMatrix3 m)
inlinevirtual

Set 'other' to 'this' transformation matrix.

Reimplemented from csTransform.

Reimplemented in csOrthoTransform.

Definition at line 241 of file optransfrm.h.

References csMatrix3::GetInverse(), csTransform::m_o2t, and m_t2o.

242  { m_o2t = m; m_t2o = m_o2t.GetInverse (); }
virtual void csReversibleTransform::SetT2O ( const csMatrix3 m)
inlinevirtual

Set 'this' to 'other' transformation matrix.

Reimplemented in csOrthoTransform.

Definition at line 247 of file optransfrm.h.

References csMatrix3::GetInverse(), csTransform::m_o2t, and m_t2o.

Referenced by RotateOther(), and RotateThis().

248  { m_t2o = m; m_o2t = m_t2o.GetInverse (); }
csVector3 csReversibleTransform::This2Other ( const csVector3 v) const
inline

Convert vector v in 'this' space to 'other' space. This is the basic inverse transform operation.

Definition at line 254 of file optransfrm.h.

References m_t2o, v, and csTransform::v_o2t.

255  { return v_o2t + m_t2o * v; }
csVector3 csReversibleTransform::This2OtherRelative ( const csVector3 v) const
inline

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

Definition at line 261 of file optransfrm.h.

References m_t2o, and v.

262  { return m_t2o * v; }

Friends And Related Function Documentation

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

Combine two transforms, with the rightmost being applied first.

Definition at line 338 of file optransfrm.h.

340  {
341  return csReversibleTransform (t1.m_o2t*t2.m_o2t, t2.m_t2o*t1.m_t2o,
342  t2.v_o2t + t2.m_t2o*t1.v_o2t);
343  }
csTransform operator* ( const csTransform t1,
const csReversibleTransform t2 
)
friend

Combine two transforms, with the rightmost being applied first.

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

Reverse a transformation on a Plane.

Reverse a transformation on a Plane. Combine two transforms, with the rightmost being applied first.

Definition at line 328 of file optransfrm.h.

330  {
331  t1.v_o2t = t2.m_t2o*t1.v_o2t;
332  t1.v_o2t += t2.v_o2t;
333  t1.m_o2t *= t2.m_o2t;
334  t1.m_t2o *= t1.m_t2o;
335  return t1;
336  }
csVector3 operator/ ( const csVector3 v,
const csReversibleTransform t 
)
friend

Reverse a transformation on a 3D vector.

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

Combine two transforms, reversing t2 then applying t1.

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

Reverse a transformation on a 3D vector.

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

Combine two transforms, reversing t2 then applying t1.

Member Data Documentation

csMatrix3 csReversibleTransform::m_t2o
protected

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

Definition at line 176 of file optransfrm.h.

Referenced by csReversibleTransform(), GetInverse(), GetT2O(), RotateOther(), RotateThis(), SetO2T(), csOrthoTransform::SetO2T(), SetT2O(), csOrthoTransform::SetT2O(), This2Other(), and This2OtherRelative().


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