V-ART
transform.h
Go to the documentation of this file.
1 
5 #ifndef VART_TRANSFORM_H
6 #define VART_TRANSFORM_H
7 
8 #include "vart/point4d.h"
9 #include "vart/scenenode.h"
10 #include <iostream>
11 #include <iomanip>
12 #include <cmath>
13 
14 namespace VART {
15  class BoundingBox;
24  class Transform : public SceneNode {
26  friend std::ostream& operator<<(std::ostream& output, const Transform& t);
27  public:
29  Transform();
30 
33  Transform(const Transform& trans);
34 
37  virtual VART::SceneNode * Copy();
38 
40  void MakeIdentity();
41 
45  Point4D operator*(const Point4D& point) const;
46 
50  Transform operator*(const Transform& t) const;
51 
53  Transform& operator=(const Transform& t);
54 
56  void Apply(const Transform& t);
57 
60  void ApplyTo(Point4D* ptPoint) const;
61 
66  void MakeTranslation(const Point4D& translationVector);
67 
72  void MakeTranslation(double tx, double ty, double tz)
73  { MakeTranslation(Point4D(tx,ty,tz,0)); }
74 
77  void MakeXRotation(double radians);
78 
81  void MakeYRotation(double radians);
82 
85  void MakeZRotation(double radians);
86 
90  void MakeRotation(const Point4D& refVec, const float radians);
91 
96  void MakeRotation(const Point4D& refPoint, const Point4D& refVec, const float radians);
97 
99  void MakeScale(double sX, double sY, double sZ);
100 
102  void MakeShear(double shX, double shY);
103 
105  void SetData(double* data);
106 
111  const double* GetData() const { return matrix; }
112 
118  void GetVectorX(Point4D* result) const;
119 
125  void GetVectorY(Point4D* result) const;
126 
132  void GetVectorZ(Point4D* result) const;
133 
135  void GetTranslation(Point4D* result) const;
136 
140  #ifndef NDEBUG
141  bool HasNaN() const;
142  #endif
143 
146  virtual bool DrawOGL() const;
147 
152  virtual void DrawForPicking() const;
153 
154  virtual TypeID GetID() const { return TRANSFORM; }
155 
159  virtual bool RecursiveBoundingBox(BoundingBox* bBox);
160 
162  void ToggleRecVisibility();
163 
167  void CopyMatrix(const Transform& t);
168 
169  protected:
170  // PROTECTED ATTRIBUTES
171  double matrix[16];
172  private:
173  // PRIVATE METHODS
174  bool Zero(const double& n) { return (fabs(n) < 0.0000001); }
175  }; // end class declaration
176 } // end namespace
177 #endif
void SetData(double *data)
Set all data in the transform.
Definition: transform.cpp:33
void ToggleRecVisibility()
Toggles the recursive object's visibility.
Definition: transform.cpp:340
Base class for objects that compose a scene graph.
Definition: scenenode.h:25
Points and vectors using homogeneous coordinates.
Definition: point4d.h:22
Point4D operator*(const Point4D &point) const
Applies transformation to a point.
Definition: transform.cpp:106
void MakeRotation(const Point4D &refVec, const float radians)
Turns transform into a rotation (around some reference vetor).
Definition: transform.cpp:171
Header file for V-ART class "SceneNode".
void ApplyTo(Point4D *ptPoint) const
Applies tranformation to a point.
Definition: transform.cpp:149
Transform & operator=(const Transform &t)
Copies data from anoter transform.
Definition: transform.cpp:130
void MakeTranslation(const Point4D &translationVector)
Turns transform into a translation.
Definition: transform.cpp:56
friend std::ostream & operator<<(std::ostream &output, const Transform &t)
'ostream' class extension to output a transformation on the console.
Axis aligned bounding box.
Definition: boundingbox.h:23
void MakeXRotation(double radians)
Turns transform into a rotation around the X axis.
Definition: transform.cpp:64
const double * GetData() const
Returns the address of transformation matrix.
Definition: transform.h:111
Geometric transformations.
Definition: transform.h:24
void MakeTranslation(double tx, double ty, double tz)
Turns transform into a translation.
Definition: transform.h:72
void GetVectorX(Point4D *result) const
Returns the X vector of the transform.
Definition: transform.cpp:228
virtual TypeID GetID() const
Returns type identification of the node.
Definition: transform.h:154
virtual bool RecursiveBoundingBox(BoundingBox *bBox)
Returns the recursive bounding box.
Definition: transform.cpp:293
virtual VART::SceneNode * Copy()
Returns a copy of an Transform. Every derived class must reimplements this method, to avoid errors with VART::SceneNode::RecursiveCopy.
Definition: transform.cpp:28
void MakeYRotation(double radians)
Turns transform into a rotation around the Y axis.
Definition: transform.cpp:73
void MakeIdentity()
Turns transform into identity.
Definition: transform.cpp:49
double matrix[16]
Definition: transform.h:171
virtual bool DrawOGL() const
Apply transform to rendering engine.
Definition: transform.cpp:260
void MakeShear(double shX, double shY)
Turns transform into a shear.
Definition: transform.cpp:99
bool HasNaN() const
Check for NaNs inside the matrix.
Definition: transform.cpp:362
void MakeScale(double sX, double sY, double sZ)
Turns transform into a scale.
Definition: transform.cpp:91
void Apply(const Transform &t)
Applies a transformation to itself.
Definition: transform.cpp:144
Header file for V-ART class "Point4D".
void GetVectorY(Point4D *result) const
Returns the Y vector of the transform.
Definition: transform.cpp:236
void CopyMatrix(const Transform &t)
Copies matrix data from another transform.
Definition: transform.cpp:138
Transform()
Creates an uninitialized transform.
Definition: transform.cpp:24
virtual void DrawForPicking() const
Draws and object, setting pick info.
Definition: transform.cpp:278
void MakeZRotation(double radians)
Turns transform into a rotation around the Z axis.
Definition: transform.cpp:82
void GetTranslation(Point4D *result) const
Returns the translation part of the transform.
Definition: transform.cpp:252
void GetVectorZ(Point4D *result) const
Returns the Z vector of the transform.
Definition: transform.cpp:244