DATAKIT API  V2025.1
Dtk_transfo Class Referenceabstract

This is the Transformation dedicated class. More...

+ Inheritance diagram for Dtk_transfo:

Public Member Functions

void addRotate_axeZ (Dtk_Double64 angle)
 2D operation, not yet generalized but soon More...
 
void addScale (Dtk_Double64)
 Add a scale. More...
 
void addTranslate (const Dtk_dir &V)
 Translate the Dtk_transfo. More...
 
 Dtk_transfo ()
 default constructor More...
 
 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. More...
 
 Dtk_transfo (const Dtk_matrix &m)
 copy constructor More...
 
 Dtk_transfo (Dtk_Double64 *d, Dtk_Int32 typefill=0)
 create a tansfo from a double* More...
 
Dtk_Int32 DtkDynamicType (const Dtk_Int32 &inId)
 
virtual int DtkDynamicType (const int &inId)=0
 
virtual void dump (FILE *file=stdout)
 
Dtk_matrixGetDtkMatrix ()
 Dtk_matrix conversion. More...
 
const double & getOcomponent (Dtk_Int32 n) const
 Return the n component of the O center point. More...
 
const Dtk_pntgetOrigin () const
 Return the O center point of the Dtk_transfo (the center O of the basis) More...
 
const double & getScale () const
 Retrieves the scale factor. More...
 
virtual Dtk_Size_t GetSize () const
 
const double & getXcomponent (Dtk_Int32 n) const
 Return the n component of the X vector. More...
 
const Dtk_dirgetXdir () const
 Return the X vector. More...
 
const double & getYcomponent (Dtk_Int32 n) const
 Return the n component of the Y vector. More...
 
const Dtk_dirgetYdir () const
 Return the Y vector. More...
 
const double & getZcomponent (Dtk_Int32 n) const
 Return the n component of the Z vector. More...
 
const Dtk_dirgetZdir () const
 Return the Z vector. More...
 
int inverse ()
 Inverse the current Matrix. More...
 
int is_identity () const
 Is transformation Identity. More...
 
Dtk_bool IsDirect () const
 Is direct. More...
 
Dtk_bool IsNormalized (const Dtk_Double64 &inTol=DTK_TOLERANCE) const
 Is normalized. More...
 
void Normalize ()
 
int operator== (const Dtk_transfo &in) const
 Compare 2 Dtk_transfo matrix. More...
 
double scale () const
 Obsolete : use getScale instead. More...
 
void setAxisRotation (Dtk_dir axis, Dtk_Double64 angle)
 turn the basis represented by Dtk_transfo around a given vector with origin on (0.0, 0.0, 0.0) and scale equal to 1.0 More...
 
void setOrigin (const Dtk_pnt &O)
 Set a new O center point. More...
 
void setOrigin (Dtk_Double64 x, Dtk_Double64 y, Dtk_Double64 z)
 Set a new O center point by giving its components. More...
 
void setScale (Dtk_Double64 scale)
 Set a new scale. More...
 
void setXdir (const Dtk_dir &X)
 Set a new X vector. More...
 
void setXdir (Dtk_Double64 x, Dtk_Double64 y, Dtk_Double64 z)
 Set a new X vector by giving its components. More...
 
void setYdir (const Dtk_dir &Y)
 Set a new Y vector. More...
 
void setYdir (Dtk_Double64 x, Dtk_Double64 y, Dtk_Double64 z)
 Set a new Y vector by giving its components. More...
 
void setZdir (const Dtk_dir &Z)
 Set a new Z vector. More...
 
void setZdir (Dtk_Double64 x, Dtk_Double64 y, Dtk_Double64 z)
 Set a new Z vector by giving its components. More...
 
 ~Dtk_transfo ()
 Destructor. More...
 

Static Public Member Functions

static Dtk_SmartPtr< Dtk_transfocreate ()
 
static Dtk_SmartPtr< Dtk_transfocreate (const Dtk_transfo &)
 
static Dtk_transfoDtkDynamicCast (Dtk_Object *s)
 

Protected Types

enum  { _typeID = DTK_TYPE_OBJECT }
 

Protected Member Functions

void _copy (const Dtk_Object &s)
 
void _copy (const Dtk_transfo &s)
 
void _init ()
 
void _reset ()
 

Protected Attributes

unsigned long count_
 
Dtk_pnt o
 
double sc
 
Dtk_dir v [3]
 

Friends

class Dtk_SmartPtr< Dtk_transfo >
 
Dtk_transfo Dtk_transfoPtr_to_Dtk_transfo (Dtk_SmartPtr< Dtk_transfo > &t)
 
Dtk_transfo operator* (const Dtk_transfo &, const Dtk_transfo &)
 Allow to multiply 2 Dtk_transfo (matrix multiplication) More...
 
Dtk_dir operator* (const Dtk_transfo &M, const Dtk_dir &P)
 Allow to multiply a Dtk_transfo by a vector. More...
 
Dtk_transfo operator* (const Dtk_transfo &M, const Dtk_Double64 d)
 Multiply a matrix by a scalar number. More...
 
Dtk_pnt operator* (const Dtk_transfo &M, const Dtk_pnt &P)
 Allow to multiply a Dtk_transfo by a point. More...
 
Dtk_transfo operator+ (const Dtk_transfo &t1, const Dtk_transfo &t2)
 Allow to add 2 Dtk_transfo (matrix addition) More...
 
Dtk_transfo operator- (const Dtk_transfo &t1, const Dtk_transfo &t2)
 Allow to substracte 2 Dtk_transfo (matrix difference) More...
 
Dtk_transfo operator/ (Dtk_transfo &M, Dtk_Double64 d)
 Divide a matrix by a scalar number. More...
 
std::ostream & operator<< (std::ostream &o, const Dtk_transfo &d)
 

Detailed Description

This is the Transformation dedicated class.

A transformation a matrix is a basis : it contain a point, 3 vectors X,Y,Z, and a global scale.

Note that the implementation allow you to unnormalize the vectors if really needed (distortion matrix), but it is suggested that the X,Y,Z vectors are normalized, and the scale parameter define the global scale

This class lets you use transformation.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protectedinherited
Enumerator
_typeID 

Constructor & Destructor Documentation

◆ Dtk_transfo() [1/4]

Dtk_transfo::Dtk_transfo ( )

default constructor

◆ Dtk_transfo() [2/4]

Dtk_transfo::Dtk_transfo ( Dtk_Double64 d,
Dtk_Int32  typefill = 0 
)

create a tansfo from a double*

Parameters
[in]darray of double
[in]typefillmethod to fill (see below)

0 (default) : 13 elements : Xx,Xy,Xz,Yx,Yy,Yz,Zx,Zy,Zz,Ox,Oy,Oz,GlobalScale

◆ Dtk_transfo() [3/4]

Dtk_transfo::Dtk_transfo ( const Dtk_matrix m)

copy constructor

Parameters
[in]mthe matrix to be copied
Warning
m must be a 4x4 or 4x3 Dtk_matrix

◆ Dtk_transfo() [4/4]

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.

Parameters
[in]Xthe X direction.
[in]Ythe Y direction.
[in]Zthe Z direction.
[in]Othe Origin.
[in]scalethe scale factor : default is 1.0

◆ ~Dtk_transfo()

Dtk_transfo::~Dtk_transfo ( )

Destructor.

Member Function Documentation

◆ _copy() [1/2]

void Dtk_Object::_copy ( const Dtk_Object s)
protectedinherited

◆ _copy() [2/2]

void Dtk_transfo::_copy ( const Dtk_transfo s)
protected

◆ _init()

void Dtk_transfo::_init ( )
protected

◆ _reset()

void Dtk_transfo::_reset ( )
protected

◆ addRotate_axeZ()

void Dtk_transfo::addRotate_axeZ ( Dtk_Double64  angle)

2D operation, not yet generalized but soon

turn the basis represented by Dtk_transfo around Z vector

Parameters
[in]angleangle of rotation (radian)

◆ addScale()

void Dtk_transfo::addScale ( Dtk_Double64  )

Add a scale.

Mathematics : just multiply the current scale by the given scale

Parameters
[in]scalescale to add.

◆ addTranslate()

void Dtk_transfo::addTranslate ( const Dtk_dir V)

Translate the Dtk_transfo.

Mathematics : just sum the given vector to the O center point.

Parameters
[in]Vvector

◆ create() [1/2]

static Dtk_SmartPtr<Dtk_transfo> Dtk_transfo::create ( )
static

◆ create() [2/2]

static Dtk_SmartPtr<Dtk_transfo> Dtk_transfo::create ( const Dtk_transfo )
static

◆ DtkDynamicCast()

static Dtk_transfo* Dtk_transfo::DtkDynamicCast ( Dtk_Object s)
static

◆ DtkDynamicType() [1/2]

Dtk_Int32 Dtk_transfo::DtkDynamicType ( const Dtk_Int32 inId)

◆ DtkDynamicType() [2/2]

◆ dump()

virtual void Dtk_Object::dump ( FILE *  file = stdout)
virtualinherited

◆ GetDtkMatrix()

Dtk_matrix* Dtk_transfo::GetDtkMatrix ( )

Dtk_matrix conversion.

Returns
Dtk_matrix corresponding

◆ getOcomponent()

const double& Dtk_transfo::getOcomponent ( Dtk_Int32  n) const

Return the n component of the O center point.

Parameters
[in]ncoordinate of the O center point
Returns
the n component of the O center point

◆ getOrigin()

const Dtk_pnt& Dtk_transfo::getOrigin ( ) const

Return the O center point of the Dtk_transfo (the center O of the basis)

Returns
the O Dtk_pnt

◆ getScale()

const double& Dtk_transfo::getScale ( ) const

Retrieves the scale factor.

Returns
the scale factor.

◆ GetSize()

◆ getXcomponent()

const double& Dtk_transfo::getXcomponent ( Dtk_Int32  n) const

Return the n component of the X vector.

Parameters
[in]ncoordinate of the X vector to return.
Returns
the n component of the X vector

◆ getXdir()

const Dtk_dir& Dtk_transfo::getXdir ( ) const

Return the X vector.

Returns
the X Dtk_dir

◆ getYcomponent()

const double& Dtk_transfo::getYcomponent ( Dtk_Int32  n) const

Return the n component of the Y vector.

Parameters
[in]ncoordinate of the Y vector to return.
Returns
the n component of the Y vector

◆ getYdir()

const Dtk_dir& Dtk_transfo::getYdir ( ) const

Return the Y vector.

Returns
the Y Dtk_dir

◆ getZcomponent()

const double& Dtk_transfo::getZcomponent ( Dtk_Int32  n) const

Return the n component of the Z vector.

Parameters
[in]ncoordinate of the Z vector to return.
Returns
the n component of the Z vector

◆ getZdir()

const Dtk_dir& Dtk_transfo::getZdir ( ) const

Return the Z vector.

Returns
the Z Dtk_dir

◆ inverse()

int Dtk_transfo::inverse ( )

Inverse the current Matrix.

Returns
0 is success, -1 otherwise

◆ is_identity()

int Dtk_transfo::is_identity ( ) const

Is transformation Identity.

Returns
1 if is identity 0 if not.

◆ IsDirect()

Dtk_bool Dtk_transfo::IsDirect ( ) const

Is direct.

Returns
1 if transformation is direct 0 if not.

◆ IsNormalized()

Dtk_bool Dtk_transfo::IsNormalized ( const Dtk_Double64 inTol = DTK_TOLERANCE) const

Is normalized.

Returns
1 if rotation vector are normalized 0 if not.

◆ Normalize()

void Dtk_transfo::Normalize ( )
253  {
254  v[ 0 ].normalize();
255  v[ 1 ].normalize();
256  v[ 2 ].normalize();
257 
258  }

◆ operator==()

int Dtk_transfo::operator== ( const Dtk_transfo in) const

Compare 2 Dtk_transfo matrix.

Parameters
[in]inthe Dtk_transfo to test with this.
Returns
1 if equal, 0 if not.

◆ scale()

double Dtk_transfo::scale ( ) const

Obsolete : use getScale instead.

◆ setAxisRotation()

void Dtk_transfo::setAxisRotation ( Dtk_dir  axis,
Dtk_Double64  angle 
)

turn the basis represented by Dtk_transfo around a given vector with origin on (0.0, 0.0, 0.0) and scale equal to 1.0

Parameters
[in]axisaxis of the ratation
[in]angleangle of rotation (radian)

◆ setOrigin() [1/2]

void Dtk_transfo::setOrigin ( const Dtk_pnt O)

Set a new O center point.

Parameters
[in]Othe new O point

◆ setOrigin() [2/2]

void Dtk_transfo::setOrigin ( Dtk_Double64  x,
Dtk_Double64  y,
Dtk_Double64  z 
)

Set a new O center point by giving its components.

Parameters
[in]xthe x component of the O center point
[in]ythe y component of the O center point
[in]zthe z component of the O center point

◆ setScale()

void Dtk_transfo::setScale ( Dtk_Double64  scale)

Set a new scale.

Parameters
[in]scalethe new scale.
Returns
the scale factor (get/set).

◆ setXdir() [1/2]

void Dtk_transfo::setXdir ( const Dtk_dir X)

Set a new X vector.

Parameters
[in]Xthe new X vector

◆ setXdir() [2/2]

void Dtk_transfo::setXdir ( Dtk_Double64  x,
Dtk_Double64  y,
Dtk_Double64  z 
)

Set a new X vector by giving its components.

Parameters
[in]xthe x component of the X vector
[in]ythe y component of the X vector
[in]zthe z component of the X vector

◆ setYdir() [1/2]

void Dtk_transfo::setYdir ( const Dtk_dir Y)

Set a new Y vector.

Parameters
[in]Ythe new Y vector

◆ setYdir() [2/2]

void Dtk_transfo::setYdir ( Dtk_Double64  x,
Dtk_Double64  y,
Dtk_Double64  z 
)

Set a new Y vector by giving its components.

Parameters
[in]xthe x component of the Y vector
[in]ythe y component of the Y vector
[in]zthe z component of the Y vector

◆ setZdir() [1/2]

void Dtk_transfo::setZdir ( const Dtk_dir Z)

Set a new Z vector.

Parameters
[in]Zthe new Z vector

◆ setZdir() [2/2]

void Dtk_transfo::setZdir ( Dtk_Double64  x,
Dtk_Double64  y,
Dtk_Double64  z 
)

Set a new Z vector by giving its components.

Parameters
[in]xthe x component of the Z vector
[in]ythe y component of the Z vector
[in]zthe z component of the Z vector

Friends And Related Function Documentation

◆ Dtk_SmartPtr< Dtk_transfo >

friend class Dtk_SmartPtr< Dtk_transfo >
friend

◆ Dtk_transfoPtr_to_Dtk_transfo

Dtk_transfo Dtk_transfoPtr_to_Dtk_transfo ( Dtk_SmartPtr< Dtk_transfo > &  t)
friend

◆ operator* [1/4]

Dtk_transfo operator* ( const Dtk_transfo ,
const Dtk_transfo  
)
friend

Allow to multiply 2 Dtk_transfo (matrix multiplication)

Parameters
[in]t1first matrix to multiply
[in]t2second matrix to multiply
Returns
the product t1*t2

◆ operator* [2/4]

Dtk_dir operator* ( const Dtk_transfo M,
const Dtk_dir P 
)
friend

Allow to multiply a Dtk_transfo by a vector.

Parameters
[in]Mmatrix to multiply
[in]Pvector to multiply by
Returns
the vector M*P

◆ operator* [3/4]

Dtk_transfo operator* ( const Dtk_transfo M,
const Dtk_Double64  d 
)
friend

Multiply a matrix by a scalar number.

whole datas are multiplied.

Parameters
[in]Mmatrix to multiply
[in]dscalar
Returns
the vector M*d

◆ operator* [4/4]

Dtk_pnt operator* ( const Dtk_transfo M,
const Dtk_pnt P 
)
friend

Allow to multiply a Dtk_transfo by a point.

Parameters
[in]Mmatrix to multiply
[in]Ppoint to multiply by
Returns
the point M*P

◆ operator+

Dtk_transfo operator+ ( const Dtk_transfo t1,
const Dtk_transfo t2 
)
friend

Allow to add 2 Dtk_transfo (matrix addition)

Parameters
[in]t1first matrix to add
[in]t2second matrix to add
Returns
the sum t1+t2

◆ operator-

Dtk_transfo operator- ( const Dtk_transfo t1,
const Dtk_transfo t2 
)
friend

Allow to substracte 2 Dtk_transfo (matrix difference)

Parameters
[in]t1first matrix to substracte
[in]t2second matrix to substracte
Returns
the difference t1-t2

◆ operator/

Dtk_transfo operator/ ( Dtk_transfo M,
Dtk_Double64  d 
)
friend

Divide a matrix by a scalar number.

whole datas are divided.

Parameters
[in]Mmatrix to divide
[in]dscalar
Returns
the vector M/d

◆ operator<<

std::ostream& operator<< ( std::ostream &  o,
const Dtk_transfo d 
)
friend

Field Documentation

◆ count_

unsigned long Dtk_Object::count_
protectedinherited

◆ o

Dtk_pnt Dtk_transfo::o
protected

◆ sc

double Dtk_transfo::sc
protected

◆ v

Dtk_dir Dtk_transfo::v[3]
protected
DTK_TYPE_OBJECT
@ DTK_TYPE_OBJECT
Definition: define.h:464
Dtk_transfo::v
Dtk_dir v[3]
Definition: dtk_transfo.hpp:22
Dtk_dir::normalize
int normalize()
Dtk_Object::_typeID
@ _typeID
Definition: dtk_object.hpp:13