DATAKIT API  V2025.1
dtk_transfo.hpp
Go to the documentation of this file.
1 #ifndef __DTK_TRANSFO_HPP__
2 #define __DTK_TRANSFO_HPP__
3 
4 #include "struct/str_def.h"
9 #include <def/define.h>
10 
18 class Dtk_transfo:public Dtk_Object
19 {
20 protected:
21  //enum { _typeID = DTK_TYPE_TRANSFO };
22  Dtk_dir v[ 3 ];
24  double sc;
25  void _init();
26  void _copy( const Dtk_transfo& s );
27  void _reset();
28 public:
29 
30  //downcasting
33 
42  Dtk_transfo( Dtk_Double64* d, Dtk_Int32 typefill = 0 );
47  Dtk_transfo( const Dtk_matrix& m );
54  Dtk_transfo( const Dtk_dir& X, const Dtk_dir& Y, const Dtk_dir& Z, const Dtk_pnt& O, const Dtk_Double64& scale = 1.0 );
62  int operator ==( const Dtk_transfo& in ) const;
66  int is_identity() const;
67 
72 
76  Dtk_bool IsDirect() const;
77 
80  double scale() const;
84  const double& getScale() const;
90  //Dtk_pnt getO(); // deprecated.
91  //Dtk_dir getVect(int n,bool normalize=false); // deprecated.
95  const Dtk_dir& getXdir() const;
99  const Dtk_dir& getYdir() const;
103  const Dtk_dir& getZdir() const;
107  const Dtk_pnt& getOrigin() const;
112  const double& getXcomponent( Dtk_Int32 n ) const;
117  const double& getYcomponent( Dtk_Int32 n ) const;
122  const double& getZcomponent( Dtk_Int32 n ) const;
127  const double& getOcomponent( Dtk_Int32 n ) const;
131  void setXdir( const Dtk_dir& X );
135  void setYdir( const Dtk_dir& Y );
139  void setZdir( const Dtk_dir& Z );
143  void setOrigin( const Dtk_pnt& O );
171  int inverse();
177  friend Dtk_transfo operator*( const Dtk_transfo&, const Dtk_transfo& );
183  friend Dtk_pnt operator*( const Dtk_transfo& M, const Dtk_pnt& P );
189  friend Dtk_dir operator*( const Dtk_transfo& M, const Dtk_dir& P );
196  friend Dtk_transfo operator*( const Dtk_transfo& M, const Dtk_Double64 d );
209  friend Dtk_transfo operator+( const Dtk_transfo& t1, const Dtk_transfo& t2 );
215  friend Dtk_transfo operator-( const Dtk_transfo& t1, const Dtk_transfo& t2 );
216  //friend Dtk_transfo operator+=(Dtk_transfo& t1,const Dtk_transfo& t2); // deprecated
217  //friend Dtk_transfo operator-=(Dtk_transfo& t1,const Dtk_transfo& t2); // deprecated
218 
219  //void Decompose_TS(Dtk_transfo& T,Dtk_transfo& S); // deprecated
220  //void Decompose_ST(Dtk_transfo& S,Dtk_transfo& T); // deprecated
221 
226  void addTranslate( const Dtk_dir& V );
232 
237  void setAxisRotation( Dtk_dir axis, Dtk_Double64 angle );
238 
239  //void addRotate_axeX(double angle);
240  //void addRotate_axeY(double angle);
246 
251 
252  void Normalize()
253  {
254  v[ 0 ].normalize();
255  v[ 1 ].normalize();
256  v[ 2 ].normalize();
257 
258  }
259 
260 
261 
262 private:
263  friend class Dtk_SmartPtr<Dtk_transfo>;
264  friend std::ostream& operator<<( std::ostream& o, const Dtk_transfo& d );
266 };
267 
268 
269 #endif //#ifndef __DTK_TRANSFO_HPP__
Dtk_transfo::o
Dtk_pnt o
Definition: dtk_transfo.hpp:23
Dtk_transfo
This is the Transformation dedicated class.
Definition: dtk_transfo.hpp:19
dtk_matrix.hpp
Dtk_transfo::setOrigin
void setOrigin(Dtk_Double64 x, Dtk_Double64 y, Dtk_Double64 z)
Set a new O center point by giving its components.
dtk_dir.hpp
Dtk_transfo::operator*
friend Dtk_pnt operator*(const Dtk_transfo &M, const Dtk_pnt &P)
Allow to multiply a Dtk_transfo by a point.
DTK_TOLERANCE
#define DTK_TOLERANCE
Definition: str_def.h:7
Dtk_transfo::setAxisRotation
void setAxisRotation(Dtk_dir axis, Dtk_Double64 angle)
turn the basis represented by Dtk_transfo around a given vector with origin on (0....
Dtk_transfo::getOrigin
const Dtk_pnt & getOrigin() const
Return the O center point of the Dtk_transfo (the center O of the basis)
Dtk_transfo::setOrigin
void setOrigin(const Dtk_pnt &O)
Set a new O center point.
Dtk_transfo::create
static Dtk_SmartPtr< Dtk_transfo > create()
Dtk_transfo::setZdir
void setZdir(const Dtk_dir &Z)
Set a new Z vector.
Dtk_transfo::getOcomponent
const double & getOcomponent(Dtk_Int32 n) const
Return the n component of the O center point.
Dtk_transfo::Dtk_transfoPtr_to_Dtk_transfo
friend Dtk_transfo Dtk_transfoPtr_to_Dtk_transfo(Dtk_SmartPtr< Dtk_transfo > &t)
Dtk_transfo::_init
void _init()
Dtk_transfo::addRotate_axeZ
void addRotate_axeZ(Dtk_Double64 angle)
2D operation, not yet generalized but soon
Dtk_transfo::getZcomponent
const double & getZcomponent(Dtk_Int32 n) const
Return the n component of the Z vector.
Dtk_transfo::operator==
int operator==(const Dtk_transfo &in) const
Compare 2 Dtk_transfo matrix.
Dtk_bool
char Dtk_bool
Definition: define.h:725
Dtk_transfo::scale
double scale() const
Obsolete : use getScale instead.
Dtk_Double64
double Dtk_Double64
Definition: define.h:699
Dtk_transfo::setXdir
void setXdir(const Dtk_dir &X)
Set a new X vector.
Dtk_transfo::operator<<
friend std::ostream & operator<<(std::ostream &o, const Dtk_transfo &d)
Dtk_transfo::getZdir
const Dtk_dir & getZdir() const
Return the Z vector.
dtk_pnt.hpp
Dtk_transfo::GetDtkMatrix
Dtk_matrix * GetDtkMatrix()
Dtk_matrix conversion.
Dtk_transfo::_copy
void _copy(const Dtk_transfo &s)
Dtk_Int32
int32_t Dtk_Int32
Definition: define.h:687
Dtk_transfo::Dtk_transfo
Dtk_transfo(const Dtk_dir &X, const Dtk_dir &Y, const Dtk_dir &Z, const Dtk_pnt &O, const Dtk_Double64 &scale=1.0)
Full featured constructor.
Dtk_transfo::Normalize
void Normalize()
Definition: dtk_transfo.hpp:252
Dtk_transfo::operator-
friend Dtk_transfo operator-(const Dtk_transfo &t1, const Dtk_transfo &t2)
Allow to substracte 2 Dtk_transfo (matrix difference)
Dtk_transfo::v
Dtk_dir v[3]
Definition: dtk_transfo.hpp:22
Dtk_transfo::is_identity
int is_identity() const
Is transformation Identity.
Dtk_transfo::~Dtk_transfo
~Dtk_transfo()
Destructor.
Dtk_matrix
Definition: dtk_matrix.hpp:8
Dtk_transfo::IsDirect
Dtk_bool IsDirect() const
Is direct.
Dtk_transfo::getXdir
const Dtk_dir & getXdir() const
Return the X vector.
Dtk_transfo::setZdir
void setZdir(Dtk_Double64 x, Dtk_Double64 y, Dtk_Double64 z)
Set a new Z vector by giving its components.
Dtk_transfo::setScale
void setScale(Dtk_Double64 scale)
Set a new scale.
Dtk_SmartPtr
Definition: util_ptr_dtk.hpp:37
Dtk_transfo::_reset
void _reset()
Dtk_transfo::operator*
friend Dtk_transfo operator*(const Dtk_transfo &M, const Dtk_Double64 d)
Multiply a matrix by a scalar number.
Dtk_transfo::getScale
const double & getScale() const
Retrieves the scale factor.
Dtk_transfo::operator*
friend Dtk_dir operator*(const Dtk_transfo &M, const Dtk_dir &P)
Allow to multiply a Dtk_transfo by a vector.
Dtk_dir::normalize
int normalize()
Dtk_transfo::setYdir
void setYdir(const Dtk_dir &Y)
Set a new Y vector.
Dtk_pnt
This is a mathematical point class.
Definition: dtk_pnt.hpp:22
str_def.h
Dtk_transfo::getYcomponent
const double & getYcomponent(Dtk_Int32 n) const
Return the n component of the Y vector.
Dtk_transfo::Dtk_transfo
Dtk_transfo(const Dtk_matrix &m)
copy constructor
Dtk_transfo::getXcomponent
const double & getXcomponent(Dtk_Int32 n) const
Return the n component of the X vector.
Dtk_transfo::operator+
friend Dtk_transfo operator+(const Dtk_transfo &t1, const Dtk_transfo &t2)
Allow to add 2 Dtk_transfo (matrix addition)
Dtk_transfo::Dtk_transfo
Dtk_transfo()
default constructor
Dtk_transfo::DtkDynamicCast
static Dtk_transfo * DtkDynamicCast(Dtk_Object *s)
Dtk_transfo::setYdir
void setYdir(Dtk_Double64 x, Dtk_Double64 y, Dtk_Double64 z)
Set a new Y vector by giving its components.
Dtk_transfo::sc
double sc
Definition: dtk_transfo.hpp:24
define.h
Dtk_transfo::inverse
int inverse()
Inverse the current Matrix.
Dtk_transfo::addTranslate
void addTranslate(const Dtk_dir &V)
Translate the Dtk_transfo.
Dtk_transfo::addScale
void addScale(Dtk_Double64)
Add a scale.
Dtk_transfo::getYdir
const Dtk_dir & getYdir() const
Return the Y vector.
Dtk_transfo::create
static Dtk_SmartPtr< Dtk_transfo > create(const Dtk_transfo &)
Dtk_Object
Definition: dtk_object.hpp:8
Dtk_transfo::setXdir
void setXdir(Dtk_Double64 x, Dtk_Double64 y, Dtk_Double64 z)
Set a new X vector by giving its components.
Dtk_transfo::operator/
friend Dtk_transfo operator/(Dtk_transfo &M, Dtk_Double64 d)
Divide a matrix by a scalar number.
Dtk_transfo::DtkDynamicType
Dtk_Int32 DtkDynamicType(const Dtk_Int32 &inId)
Dtk_transfo::Dtk_transfo
Dtk_transfo(Dtk_Double64 *d, Dtk_Int32 typefill=0)
create a tansfo from a double*
Dtk_transfo::IsNormalized
Dtk_bool IsNormalized(const Dtk_Double64 &inTol=DTK_TOLERANCE) const
Is normalized.
Dtk_transfo::operator*
friend Dtk_transfo operator*(const Dtk_transfo &, const Dtk_transfo &)
Allow to multiply 2 Dtk_transfo (matrix multiplication)
Dtk_dir
This is a mathematical direction class.
Definition: dtk_dir.hpp:15
dtk_object.hpp