V-ART
Public Member Functions | Protected Attributes | Friends | List of all members
VART::Transform Class Reference

Geometric transformations. More...

#include <transform.h>

Inheritance diagram for VART::Transform:
VART::SceneNode VART::MemoryObj VART::Joint VART::BiaxialJoint VART::PolyaxialJoint VART::UniaxialJoint VART::CondylarJoint VART::EllipsoidJoint VART::SaddlelJoint VART::HingeJoint VART::PivotJoint

Public Member Functions

 Transform ()
 Creates an uninitialized transform. More...
 
 Transform (const Transform &trans)
 Copy constructor. More...
 
virtual VART::SceneNodeCopy ()
 Returns a copy of an Transform. Every derived class must reimplements this method, to avoid errors with VART::SceneNode::RecursiveCopy. More...
 
void MakeIdentity ()
 Turns transform into identity. More...
 
Point4D operator* (const Point4D &point) const
 Applies transformation to a point. More...
 
Transform operator* (const Transform &t) const
 Applies transformation to another transform. More...
 
Transformoperator= (const Transform &t)
 Copies data from anoter transform. More...
 
void Apply (const Transform &t)
 Applies a transformation to itself. More...
 
void ApplyTo (Point4D *ptPoint) const
 Applies tranformation to a point. More...
 
void MakeTranslation (const Point4D &translationVector)
 Turns transform into a translation. More...
 
void MakeTranslation (double tx, double ty, double tz)
 Turns transform into a translation. More...
 
void MakeXRotation (double radians)
 Turns transform into a rotation around the X axis. More...
 
void MakeYRotation (double radians)
 Turns transform into a rotation around the Y axis. More...
 
void MakeZRotation (double radians)
 Turns transform into a rotation around the Z axis. More...
 
void MakeRotation (const Point4D &refVec, const float radians)
 Turns transform into a rotation (around some reference vetor). More...
 
void MakeRotation (const Point4D &refPoint, const Point4D &refVec, const float radians)
 Turns transform into a rotation (around some reference axis). More...
 
void MakeScale (double sX, double sY, double sZ)
 Turns transform into a scale. More...
 
void MakeShear (double shX, double shY)
 Turns transform into a shear. More...
 
void SetData (double *data)
 Set all data in the transform. More...
 
const double * GetData () const
 Returns the address of transformation matrix. More...
 
void GetVectorX (Point4D *result) const
 Returns the X vector of the transform. More...
 
void GetVectorY (Point4D *result) const
 Returns the Y vector of the transform. More...
 
void GetVectorZ (Point4D *result) const
 Returns the Z vector of the transform. More...
 
void GetTranslation (Point4D *result) const
 Returns the translation part of the transform. More...
 
bool HasNaN () const
 Check for NaNs inside the matrix. More...
 
virtual bool DrawOGL () const
 Apply transform to rendering engine. More...
 
virtual void DrawForPicking () const
 Draws and object, setting pick info. More...
 
virtual TypeID GetID () const
 Returns type identification of the node. More...
 
virtual bool RecursiveBoundingBox (BoundingBox *bBox)
 Returns the recursive bounding box. More...
 
void ToggleRecVisibility ()
 Toggles the recursive object's visibility. More...
 
void CopyMatrix (const Transform &t)
 Copies matrix data from another transform. More...
 
- Public Member Functions inherited from VART::SceneNode
 SceneNode ()
 Creates an uninitialized scene node. More...
 
 SceneNode (SceneNode &node)
 
virtual ~SceneNode ()
 
SceneNodeoperator= (const SceneNode &node)
 
virtual SceneNodeRecursiveCopy ()
 
const std::string & GetDescription () const
 Returns a copy of the object's description. More...
 
void SetDescription (const std::string &desc)
 Changes the object's description. More...
 
void AddChild (SceneNode &child)
 Add a child at the end of child list. More...
 
bool DetachChild (SceneNode *childPtr)
 Removes a child from the child list. More...
 
void AutoDeleteChildren () const
 Deletes (dealocate memory) recursively all children marked as 'autoDelete'. More...
 
SceneNodeFindChildByName (const std::string &name) const
 Recusively searches its children for a given name. More...
 
std::list< SceneNode * > GetChilds ()
 
bool FindPathTo (SceneNode *targetPtr, SGPath *resultPtr) const
 Search target among children. More...
 
bool FindPathTo (const std::string &targetName, SGPath *resultPtr) const
 Search target among children. More...
 
int GetNodeTypeList (TypeID type, std::list< SceneNode * > &nodeList)
 Find all the nodes of with typeID 'type'. More...
 
virtual void TraverseDepthFirst (SNOperator *operatorPtr) const
 Process all children in depth-first order. More...
 
virtual void TraverseBreadthFirst (SNOperator *operatorPtr) const
 Process all children in breadth-first order. More...
 
virtual void LocateDepthFirst (SNLocator *locatorPtr) const
 Seaches for a particular scene node (depth first) More...
 
virtual void LocateBreadthFirst (SNLocator *locatorPtr) const
 Seaches for a particular scene node (breadth first) More...
 
virtual void XmlPrintOn (std::ostream &os, unsigned int indent) const
 Recursively outputs XML representation of the scene node. More...
 
- Public Member Functions inherited from VART::MemoryObj
 MemoryObj ()
 Default constructor. More...
 
 MemoryObj (const VART::MemoryObj &obj)
 Copy constructor. More...
 

Protected Attributes

double matrix [16]
 
- Protected Attributes inherited from VART::SceneNode
std::list< SceneNode * > childList
 Child list. More...
 
std::string description
 Textual identification. More...
 

Friends

std::ostream & operator<< (std::ostream &output, const Transform &t)
 'ostream' class extension to output a transformation on the console. More...
 

Additional Inherited Members

- Public Types inherited from VART::SceneNode
enum  TypeID {
  NONE, GRAPHIC_OBJ, BOX, CONE,
  CURVE, BEZIER, CYLINDER, IMAGE,
  IMAGE_2D, VOLUME, MESH_OBJECT, SPHERE,
  JOINT, BIAXIAL_JOINT, CONDYLAR_JOINT, ELLIPSOID_JOINT,
  SADDLE_JOINT, PLANE_JOINT, POLYAXIAL_JOINT, UNIAXIAL_JOINT,
  HINGE_JOINT, PIVOT_JOINT, TRANSFORM
}
 
- Public Attributes inherited from VART::MemoryObj
bool autoDelete
 
- Static Public Attributes inherited from VART::SceneNode
static bool recursivePrinting = true
 
- Protected Member Functions inherited from VART::SceneNode
virtual bool DrawInstanceOGL () const
 Non-recursive drawing - should be overriden by every derived class. More...
 
bool RecursiveFindPathTo (SceneNode *targetPtr, SGPath *resultPtr) const
 Recursive auxiliar method for FindPathTo. More...
 
bool RecursiveFindPathTo (const std::string &targetName, SGPath *resultPtr) const
 Recursive auxiliar method for FindPathTo. More...
 

Detailed Description

Geometric transformations.

A transformation matrix is represented by a 4x4 pre-multiplication matrix, i.e., to apply T1, then T2, then T3, one must multiply T3*T2*T1. Translation values are at the rightmost column. In a scene graph, the innermost transformation (the one close to the graphic object, farther away from root) is the one applied first.

Definition at line 24 of file transform.h.

Constructor & Destructor Documentation

VART::Transform::Transform ( )

Creates an uninitialized transform.

Definition at line 24 of file transform.cpp.

VART::Transform::Transform ( const Transform trans)

Copy constructor.

Parameters
trans[in] Source transform

Definition at line 44 of file transform.cpp.

Member Function Documentation

void VART::Transform::Apply ( const Transform t)

Applies a transformation to itself.

Definition at line 144 of file transform.cpp.

void VART::Transform::ApplyTo ( VART::Point4D ptPoint) const
VART::SceneNode * VART::Transform::Copy ( )
virtual

Returns a copy of an Transform. Every derived class must reimplements this method, to avoid errors with VART::SceneNode::RecursiveCopy.

Implements VART::SceneNode.

Reimplemented in VART::Joint, VART::UniaxialJoint, VART::PolyaxialJoint, and VART::BiaxialJoint.

Definition at line 28 of file transform.cpp.

void VART::Transform::CopyMatrix ( const Transform t)

Copies matrix data from another transform.

Unlike operator=, CopyMatrix copies only the internal matrix.

Definition at line 138 of file transform.cpp.

References matrix.

Referenced by VART::Dof::ApplyTransformTo(), VART::Dof::GetLim(), VART::SGPath::GetTransform(), and VART::IKChain::MoveTowardsSolution().

void VART::Transform::DrawForPicking ( ) const
virtual

Draws and object, setting pick info.

This method should be called in selection mode in order to identify objects that are selected by the mouse (see Scene::Pick).

Implements VART::SceneNode.

Definition at line 278 of file transform.cpp.

bool VART::Transform::DrawOGL ( ) const
virtual

Apply transform to rendering engine.

Returns
false if V-ART was not compiled with OpenGL support.

Reimplemented from VART::SceneNode.

Definition at line 260 of file transform.cpp.

const double* VART::Transform::GetData ( ) const
inline

Returns the address of transformation matrix.

Use this method to get an OpenGl like transformation matrix, compatible with methods such as "glLoadMatrixd" and "glMultMatrixd".

Definition at line 111 of file transform.h.

References matrix.

virtual TypeID VART::Transform::GetID ( ) const
inlinevirtual

Returns type identification of the node.

Reimplemented from VART::SceneNode.

Definition at line 154 of file transform.h.

References VART::SceneNode::TRANSFORM.

void VART::Transform::GetTranslation ( VART::Point4D result) const

Returns the translation part of the transform.

Definition at line 252 of file transform.cpp.

References VART::Point4D::SetW(), VART::Point4D::SetX(), VART::Point4D::SetY(), and VART::Point4D::SetZ().

void VART::Transform::GetVectorX ( VART::Point4D result) const

Returns the X vector of the transform.

A rigid transformation matrix may be interpreted as a coordinate system. This method returns the 1st column of the matrix which may be interpreted as the X vector of such coordinate system.

Definition at line 228 of file transform.cpp.

References VART::Point4D::SetW(), VART::Point4D::SetX(), VART::Point4D::SetY(), and VART::Point4D::SetZ().

void VART::Transform::GetVectorY ( VART::Point4D result) const

Returns the Y vector of the transform.

A rigid transformation matrix may be interpreted as a coordinate system. This method returns the 2nd column of the matrix which may be interpreted as the Y vector of such coordinate system.

Definition at line 236 of file transform.cpp.

References VART::Point4D::SetW(), VART::Point4D::SetX(), VART::Point4D::SetY(), and VART::Point4D::SetZ().

void VART::Transform::GetVectorZ ( VART::Point4D result) const

Returns the Z vector of the transform.

A rigid transformation matrix may be interpreted as a coordinate system. This method returns the 3rd column of the matrix which may be interpreted as the Z vector of such coordinate system.

Definition at line 244 of file transform.cpp.

References VART::Point4D::SetW(), VART::Point4D::SetX(), VART::Point4D::SetY(), and VART::Point4D::SetZ().

bool VART::Transform::HasNaN ( ) const

Check for NaNs inside the matrix.

This is for debugging purposes only.

Definition at line 362 of file transform.cpp.

void VART::Transform::MakeIdentity ( )

Turns transform into identity.

Definition at line 49 of file transform.cpp.

Referenced by VART::SGPath::GetTransform(), VART::XmlScene::LoadSceneNode(), and VART::IKChain::MoveTowardsSolution().

void VART::Transform::MakeRotation ( const Point4D refVec,
const float  radians 
)
void VART::Transform::MakeRotation ( const Point4D refPoint,
const Point4D refVec,
const float  radians 
)

Turns transform into a rotation (around some reference axis).

Parameters
refPoint[in] Reference point (defines an axis together with refVec)
refVec[in] Reference vector (defines an axis together with refPoint)
radians[in] Angle of rotation

Definition at line 216 of file transform.cpp.

References MakeRotation(), and MakeTranslation().

void VART::Transform::MakeScale ( double  sX,
double  sY,
double  sZ 
)

Turns transform into a scale.

Definition at line 91 of file transform.cpp.

void VART::Transform::MakeShear ( double  shX,
double  shY 
)

Turns transform into a shear.

Definition at line 99 of file transform.cpp.

void VART::Transform::MakeTranslation ( const Point4D translationVector)

Turns transform into a translation.

MakeTranslation expects a vector but actualy ignores the W coordinate.

Parameters
translationVector[in] Vector representation of the translation

Definition at line 56 of file transform.cpp.

References VART::Point4D::GetX(), VART::Point4D::GetY(), and VART::Point4D::GetZ().

Referenced by VART::Arrow::Arrow(), MakeRotation(), MakeTranslation(), VART::Camera::MoveForward(), VART::Camera::MoveSideways(), and VART::Camera::MoveUp().

void VART::Transform::MakeTranslation ( double  tx,
double  ty,
double  tz 
)
inline

Turns transform into a translation.

Parameters
tx[in] X component of translation
ty[in] Y component of translation
tz[in] Z component of translation

Definition at line 72 of file transform.h.

References MakeTranslation().

void VART::Transform::MakeXRotation ( double  radians)

Turns transform into a rotation around the X axis.

Parameters
radians[in] Angle of rotation

Definition at line 64 of file transform.cpp.

Referenced by VART::XmlScene::LoadSceneNode(), and MakeRotation().

void VART::Transform::MakeYRotation ( double  radians)

Turns transform into a rotation around the Y axis.

Parameters
radians[in] Angle of rotation

Definition at line 73 of file transform.cpp.

Referenced by VART::Arrow::Arrow(), VART::XmlScene::LoadSceneNode(), MakeRotation(), and VART::RefSystem::RefSystem().

void VART::Transform::MakeZRotation ( double  radians)

Turns transform into a rotation around the Z axis.

Parameters
radians[in] Angle of rotation

Definition at line 82 of file transform.cpp.

Referenced by VART::Arrow::Arrow(), VART::XmlScene::LoadSceneNode(), MakeRotation(), and VART::RefSystem::RefSystem().

VART::Point4D VART::Transform::operator* ( const Point4D point) const

Applies transformation to a point.

Parameters
point[in] Point to apply transformation
Returns
The transformed point.

Definition at line 106 of file transform.cpp.

References VART::Point4D::GetW(), VART::Point4D::GetX(), VART::Point4D::GetY(), and VART::Point4D::GetZ().

VART::Transform VART::Transform::operator* ( const Transform t) const

Applies transformation to another transform.

Parameters
t[in] Transform to apply transformation
Returns
The combined transform.

Definition at line 120 of file transform.cpp.

References matrix.

VART::Transform & VART::Transform::operator= ( const Transform t)

Copies data from anoter transform.

Definition at line 130 of file transform.cpp.

References matrix.

bool VART::Transform::RecursiveBoundingBox ( VART::BoundingBox bBox)
virtual
void VART::Transform::SetData ( double *  data)

Set all data in the transform.

Definition at line 33 of file transform.cpp.

Referenced by VART::XmlScene::LoadSceneNode().

void VART::Transform::ToggleRecVisibility ( )

Toggles the recursive object's visibility.

Definition at line 340 of file transform.cpp.

References VART::GraphicObj::ToggleRecVisibility(), ToggleRecVisibility(), and VART::GraphicObj::ToggleVisibility().

Referenced by VART::GraphicObj::ToggleRecVisibility(), and ToggleRecVisibility().

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  output,
const Transform t 
)
friend

'ostream' class extension to output a transformation on the console.

Member Data Documentation

double VART::Transform::matrix[16]
protected

Definition at line 171 of file transform.h.

Referenced by CopyMatrix(), GetData(), operator*(), and operator=().


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