## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# csTransform Class Reference
[Geometry utilities]

A class which defines a transformation from one coordinate system to another. More...

`#include <csgeom/transfrm.h>`

Inheritance diagram for csTransform:

[legend]
List of all members.

## Public Member Functions

| csTransform (const csMatrix3 &other2this, const csVector3 &origin_pos)
| Initialize with the given transformation.
| csTransform ()
| Initialize with the identity transformation.
csVector3 | GetFront ()
| Get the front vector in 'other' space.
const csMatrix3 & | GetO2T () const
| Get 'other' to 'this' transformation matrix.
const csVector3 & | GetO2TTranslation () const
| Get 'other' to 'this' translation.
const csVector3 & | GetOrigin () const
| Get origin of transformed coordinate system.
csVector3 | GetRight ()
| Get the right vector in 'other' space.
csVector3 | GetUp ()
| Get the up vector in 'other' space.
void | Identity ()
| Reset this transform to the identity transform.
bool | IsIdentity () const
| Returns true if this transform is an identity transform.
csSphere | Other2This (const csSphere &s) const
| Convert a sphere in 'other' space to 'this' space.
void | Other2This (const csPlane3 &p, const csVector3 &point, csPlane3 &result) const
| Convert a plane in 'other' space to 'this' space.
csPlane3 | Other2This (const csPlane3 &p) const
| Convert a plane in 'other' space to 'this' space.
csVector3 | Other2This (const csVector3 &v) const
| Transform vector in 'other' space v to a vector in 'this' space.
csPlane3 | Other2ThisRelative (const csPlane3 &p) const
| Convert a plane in 'other' space to 'this' space.
csVector3 | Other2ThisRelative (const csVector3 &v) const
| Convert vector v in 'other' space to a vector in 'this' space.
virtual void | SetO2T (const csMatrix3 &m)
| Set 'other' to 'this' transformation matrix.
virtual void | SetO2TTranslation (const csVector3 &v)
| Set 'world' to 'this' translation.
void | SetOrigin (const csVector3 &v)
| Set origin of transformed coordinate system.
void | Translate (const csVector3 &v)
| Move the 'other' to 'this' translation by a specified amount.
virtual | ~csTransform ()

## Static Public Member Functions

static csTransform | GetReflect (const csPlane3 &pl)
| Return a transform that represents a mirroring across a plane.

## Protected Attributes

csMatrix3 | m_o2t
| Transformation matrix from 'other' space to 'this' space.
csVector3 | v_o2t
| Location of the origin for 'this' space.

## Friends

csTransform | operator * (const csTransform &t1, const csReversibleTransform &t2)
| Combine two transforms, rightmost first.
csMatrix3 | operator * (const csTransform &t, const csMatrix3 &m)
| Multiply a matrix with the transformation matrix.
csMatrix3 | operator * (const csMatrix3 &m, const csTransform &t)
| Multiply a matrix with the transformation matrix.
csSphere | operator * (const csTransform &t, const csSphere &p)
| Apply a transformation to a sphere.
csSphere | operator * (const csSphere &p, const csTransform &t)
| Apply a transformation to a sphere.
csPlane3 | operator * (const csTransform &t, const csPlane3 &p)
| Apply a transformation to a Plane.
csPlane3 | operator * (const csPlane3 &p, const csTransform &t)
| Apply a transformation to a Plane.
csVector3 | operator * (const csTransform &t, const csVector3 &v)
| Apply a transformation to a 3D vector.
csVector3 | operator * (const csVector3 &v, const csTransform &t)
| Apply a transformation to a 3D vector.
csMatrix3 & | operator *= (csMatrix3 &m, const csTransform &t)
| Multiply a matrix with the transformation matrix.
csSphere & | operator *= (csSphere &p, const csTransform &t)
| Apply a transformation to a sphere.
csPlane3 & | operator *= (csPlane3 &p, const csTransform &t)
| Apply a transformation to a Plane.
csVector3 & | operator *= (csVector3 &v, const csTransform &t)
| Apply a transformation to a 3D vector.

## Detailed Description

A class which defines a transformation from one coordinate system to another.

The two coordinate systems are refered to as 'other' and 'this'. The transform defines a transformation from 'other' to 'this'.

Definition at line 47 of file transfrm.h.

## Constructor & Destructor Documentation

csTransform::csTransform | ( |  | ) | `[inline]`

| Initialize with the identity transformation. Definition at line 62 of file transfrm.h.

csTransform::csTransform | ( | const csMatrix3 & | other2this,
|  | const csVector3 & | origin_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 71 of file transfrm.h.

## Member Function Documentation

csVector3 csTransform::GetFront | ( |  | ) | `[inline]`

| Get the front vector in 'other' space. This is basically equivalent to doing: tr.This2OtherRelative (csVector3 (0, 0, 1)) but it is more efficient. Definition at line 307 of file transfrm.h.

const csMatrix3& csTransform::GetO2T | ( |  | ) | const`[inline]`

| Get 'other' to 'this' transformation matrix. This is the 3x3 matrix M from the transform equation T=M*(O-V). Definition at line 108 of file transfrm.h. Referenced by makeGLMatrix().

const csVector3& csTransform::GetO2TTranslation | ( |  | ) | const`[inline]`

| Get 'other' to 'this' translation. This is the vector V from the transform equation T=M*(O-V). This is equivalent to calling GetOrigin(). Definition at line 115 of file transfrm.h. Referenced by makeGLMatrix().

const csVector3& csTransform::GetOrigin | ( |  | ) | const`[inline]`

| Get origin of transformed coordinate system. In other words, the vector that gets 0,0,0 after transforming with Other2This(). This is equivalent to calling GetO2TTranslation(). Definition at line 122 of file transfrm.h.

static csTransform csTransform::GetReflect | ( | const csPlane3 & | pl | ) | `[static]`

| Return a transform that represents a mirroring across a plane. This function will return a csTransform which represents a reflection across the plane pl.

csVector3 csTransform::GetRight | ( |  | ) | `[inline]`

| Get the right vector in 'other' space. This is basically equivalent to doing: tr.This2OtherRelative (csVector3 (1, 0, 0)) but it is more efficient. Definition at line 321 of file transfrm.h.

csVector3 csTransform::GetUp | ( |  | ) | `[inline]`

| Get the up vector in 'other' space. This is basically equivalent to doing: tr.This2OtherRelative (csVector3 (0, 1, 0)) but it is more efficient. Definition at line 314 of file transfrm.h.

void csTransform::Identity | ( |  | ) | `[inline]`

| Reset this transform to the identity transform. Definition at line 77 of file transfrm.h.

bool csTransform::IsIdentity | ( |  | ) | const`[inline]`

| Returns true if this transform is an identity transform. This tests all fields so don't call this before every operation. Definition at line 87 of file transfrm.h. References ABS.

csSphere csTransform::Other2This | ( | const csSphere & | s | ) | const

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

void csTransform::Other2This | ( | const csPlane3 & | p,
|  | const csVector3 & | point,
|  | csPlane3 & | result
| ) | const

| Convert a plane in 'other' space to 'this' 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 in 'result' which looks like (M*N,-(M*N)*point).

csPlane3 csTransform::Other2This | ( | const csPlane3 & | p | ) | const

| Convert a plane in 'other' space to 'this' 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 (M*N,D+(M*N)*(M*V)).

csVector3 csTransform::Other2This | ( | const csVector3 & | v | ) | const`[inline]`

| Transform vector in 'other' space v to a vector in 'this' space. This is the basic transform function. This will calculate and return M*(v-V). Definition at line 155 of file transfrm.h.

csPlane3 csTransform::Other2ThisRelative | ( | const csPlane3 & | p | ) | const

| Convert a plane in 'other' space to 'this' 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 (M*N,D).

csVector3 csTransform::Other2ThisRelative | ( | const csVector3 & | v | ) | const`[inline]`

| Convert vector v in 'other' space to a vector in 'this' space. Use the origin of 'other' space. This will calculate and return M*v (so the translation or V of this transform is ignored). Definition at line 165 of file transfrm.h.

virtual void csTransform::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 in csReversibleTransform, and csOrthoTransform. Definition at line 128 of file transfrm.h.

virtual void csTransform::SetO2TTranslation | ( | const csVector3 & | v | ) | `[inline, virtual]`

| Set 'world' to 'this' translation. This is the vector V from the transform equation T=M*(O-V). This is equivalent to calling SetOrigin(). Definition at line 135 of file transfrm.h.

void csTransform::SetOrigin | ( | const csVector3 & | v | ) | `[inline]`

| Set origin of transformed coordinate system. This is equivalent to calling SetO2TTranslation(). Definition at line 141 of file transfrm.h.

void csTransform::Translate | ( | const csVector3 & | v | ) | `[inline]`

| Move the 'other' to 'this' translation by a specified amount. Basically this will add 'v' to the origin or translation of this transform so that the new transform looks like T=M*(O-(V+v)). Definition at line 148 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)
- t2.Minv is the inverse of t2.M

Then this will return a new transform T=(t1.M*t2.M)*(O-(t2.V+t2.Minv*t1.V)).

Reimplemented in csReversibleTransform.

csMatrix3 operator * | ( | const csTransform & | t,
|  | const csMatrix3 & | m
| ) | `[friend]`

| Multiply a matrix with the transformation matrix. This will calculate and return M*m.

csMatrix3 operator * | ( | const csMatrix3 & | m,
|  | const csTransform & | t
| ) | `[friend]`

| Multiply a matrix with the transformation matrix. This will calculate and return m*M.

csSphere operator * | ( | const csTransform & | t,
|  | const csSphere & | p
| ) | `[friend]`

| Apply a transformation to a sphere. This corresponds exactly to calling t.Other2This(p).

csSphere operator * | ( | const csSphere & | p,
|  | const csTransform & | t
| ) | `[friend]`

| Apply a transformation to a sphere. This corresponds exactly to calling t.Other2This(p).

csPlane3 operator * | ( | const csTransform & | t,
|  | const csPlane3 & | p
| ) | `[friend]`

| Apply a transformation to a Plane. This corresponds exactly to calling t.Other2This(p).

csPlane3 operator * | ( | const csPlane3 & | p,
|  | const csTransform & | t
| ) | `[friend]`

| Apply a transformation to a Plane. This corresponds exactly to calling t.Other2This(p).

csVector3 operator * | ( | const csTransform & | t,
|  | const csVector3 & | v
| ) | `[friend]`

| Apply a transformation to a 3D vector. This corresponds exactly to calling t.Other2This (v).

csVector3 operator * | ( | const csVector3 & | v,
|  | const csTransform & | t
| ) | `[friend]`

| Apply a transformation to a 3D vector. This corresponds exactly to calling t.Other2This (v).

csMatrix3& operator *= | ( | csMatrix3 & | m,
|  | const csTransform & | t
| ) | `[friend]`

| Multiply a matrix with the transformation matrix. This corresponds exactly to m*=M.

csSphere& operator *= | ( | csSphere & | p,
|  | const csTransform & | t
| ) | `[friend]`

| Apply a transformation to a sphere. This corresponds exactly to calling p = t.Other2This(p).

csPlane3& operator *= | ( | csPlane3 & | p,
|  | const csTransform & | t
| ) | `[friend]`

| Apply a transformation to a Plane. This corresponds exactly to calling p = t.Other2This(p).

csVector3& operator *= | ( | csVector3 & | v,
|  | const csTransform & | t
| ) | `[friend]`

| Apply a transformation to a 3D vector. This corresponds exactly to calling v = t.Other2This(v).

## Member Data Documentation

csMatrix3 csTransform::m_o2t `[protected]`

| Transformation matrix from 'other' space to 'this' space. Definition at line 51 of file transfrm.h. Referenced by csOrthoTransform::SetO2T(), and csOrthoTransform::SetT2O().

csVector3 csTransform::v_o2t `[protected]`

| Location of the origin for 'this' space. Definition at line 53 of file transfrm.h.

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

- csgeom/transfrm.h