OpenLexocad  27.0
Geom::Trsf Class Reference

#include <Trsf.h>

Public Types

enum  FormEnum {
  Identity, Rotation, Translation, PntMirror,
  Ax1Mirror, Ax2Mirror, Scale, CompoundTrsf,
  Other
}
 

Public Member Functions

 Trsf ()
 Returns the identity transformation.
More...
 
 Trsf (const Geom::Trsf2d &T)
 
 Trsf (const Geom::Mat &mat, const Geom::XYZ &location, double scale)
 
 Trsf (const Trsf &rhs)
 Copy constructor. More...
 
void setMirror (const Geom::Pnt &P)
 
void setMirror (const Geom::Ax1 &A1)
 
void setMirror (const Geom::Ax2 &A2)
 
void setRotation (const Geom::Ax1 &A1, const double Ang)
 
void setScale (const Geom::Pnt &P, const double S)
 
void setDisplacement (const Geom::Ax3 &FromSystem1, const Geom::Ax3 &ToSystem2)
 
void setTransformation (const Geom::Ax3 &FromSystem1, const Geom::Ax3 &ToSystem2)
 
void setTransformation (const Geom::Ax3 &ToSystem)
 
void setTranslation (const Geom::Vec &V)
 
void setTranslation (const Geom::Pnt &P1, const Geom::Pnt &P2)
 
void setTranslationPart (const Geom::Vec &V)
 Replaces the translation vector with the vector V.
More...
 
void translate (const Geom::Vec &V)
 Add vector V to the translation vector.
More...
 
void setScaleFactor (const double S)
 
void setValues (double a11, double a12, double a13, double a14, double a21, double a22, double a23, double a24, double a31, double a32, double a33, double a34, double Tolang, double TolDist)
 
bool isNegative () const
 
bool isIdentity () const
 
void setIdentity ()
 Sets the transformation to identity.
More...
 
Trsf::FormEnum form () const
 
double scaleFactor () const
 Returns the scale factor.
More...
 
const Geom::XYZtranslationPart () const
 Returns the translation part of the transformation's matrix
More...
 
Geom::Mat vectorialPart () const
 
const Geom::MathVectorialPart () const
 
double value (const int Row, const int Col) const
 
void invert ()
 
Trsf inverted () const
 
Trsf multiplied (const Trsf &T) const
 
Trsf operator * (const Trsf &T) const
 
void multiply (const Trsf &T)
 
void operator *= (const Trsf &T)
 
void preMultiply (const Trsf &T)
 
void power (const int N)
 
Trsf powered (const int N)
 
void transforms (double &X, double &Y, double &Z) const
 
void transforms (Geom::XYZ &Coord) const
 Transformation of a triplet XYZ with a Trsf
More...
 

Friends

class gp_GTrsf
 
class Geom::GTrsf
 

Detailed Description

Defines a non-persistent transformation in 3D space.
The following transformations are implemented :
. Translation, Rotation, Scale
. Symmetry with respect to a point, a line, a plane.
Complex transformations can be obtained by combining the
previous elementary transformations using the method
Multiply.
The transformations can be represented as follow :

V1 V2 V3 T XYZ XYZ
| a11 a12 a13 a14 | | x | | x'|
| a21 a22 a23 a24 | | y | | y'|
| a31 a32 a33 a34 | | z | = | z'|
| 0 0 0 1 | | 1 | | 1 |

Member Enumeration Documentation

◆ FormEnum

Enumerator
Identity 
Rotation 
Translation 
PntMirror 
Ax1Mirror 
Ax2Mirror 
Scale 
CompoundTrsf 
Other 

Constructor & Destructor Documentation

◆ Trsf() [1/4]

Geom::Trsf::Trsf ( )

Returns the identity transformation.

◆ Trsf() [2/4]

Geom::Trsf::Trsf ( const Geom::Trsf2d T)
explicit

Creates a 3D transformation from the 2D transformation T.
The resulting transformation has a homogeneous
vectorial part, V3, and a translation part, T3, built from T:
a11 a12
0 a13
V3 = a21 a22 0 T3
= a23
0 0 1.
0
It also has the same scale factor as T. This
guarantees (by projection) that the transformation
which would be performed by T in a plane (2D space)
is performed by the resulting transformation in the xOy
plane of the 3D space, (i.e. in the plane defined by the
origin (0., 0., 0.) and the vectors DX (1., 0., 0.), and DY
(0., 1., 0.)). The scale factor is applied to the entire space.

◆ Trsf() [3/4]

Geom::Trsf::Trsf ( const Geom::Mat mat,
const Geom::XYZ location,
double  scale 
)

◆ Trsf() [4/4]

Geom::Trsf::Trsf ( const Trsf rhs)

Copy constructor.

Member Function Documentation

◆ form()

Trsf::FormEnum Geom::Trsf::form ( ) const

Returns the nature of the transformation. It can be: an
identity transformation, a rotation, a translation, a mirror
transformation (relative to a point, an axis or a plane), a
scaling transformation, or a compound transformation.

◆ hVectorialPart()

const Geom::Mat& Geom::Trsf::hVectorialPart ( ) const

Computes the homogeneous vectorial part of the transformation.
It is a 3*3 matrix which doesn't include the scale factor.
In other words, the vectorial part of this transformation is
equal to its homogeneous vectorial part, multiplied by the scale factor.
The coefficients of this matrix must be multiplied by the
scale factor to obtain the coefficients of the transformation.

◆ invert()

void Geom::Trsf::invert ( )

◆ inverted()

Trsf Geom::Trsf::inverted ( ) const

Computes the reverse transformation
Raises an exception if the matrix of the transformation
is not inversible, it means that the scale factor is lower
or equal to Resolution from package gp.
Computes the transformation composed with T and <me>.
In a C++ implementation you can also write Tcomposed = <me> * T.
Example :
Trsf T1, T2, Tcomp; ...............
Tcomp = T2.Multiplied(T1); // or (Tcomp = T2 * T1)
Pnt P1(10.,3.,4.);
Pnt P2 = P1.Transformed(Tcomp); //using Tcomp
Pnt P3 = P1.Transformed(T1); //using T1 then T2
P3.Transform(T2); // P3 = P2 !!!

◆ isIdentity()

bool Geom::Trsf::isIdentity ( ) const

Returns true if this is an identity transformation of
In contrast to form() == Geom::Trsf::Identity this method checks the values.

◆ isNegative()

bool Geom::Trsf::isNegative ( ) const

Returns true if the determinant of the vectorial part of
this transformation is negative.

◆ multiplied()

Trsf Geom::Trsf::multiplied ( const Trsf T) const

◆ multiply()

void Geom::Trsf::multiply ( const Trsf T)

Computes the transformation composed with T and <me>.
In a C++ implementation you can also write Tcomposed = <me> * T.
Example :
Trsf T1, T2, Tcomp; ...............
//composition :
Tcomp = T2.Multiplied(T1); // or (Tcomp = T2 * T1)
// transformation of a point
Pnt P1(10.,3.,4.);
Pnt P2 = P1.Transformed(Tcomp); //using Tcomp
Pnt P3 = P1.Transformed(T1); //using T1 then T2
P3.Transform(T2); // P3 = P2 !!!

◆ operator *()

Trsf Geom::Trsf::operator * ( const Trsf T) const
inline

◆ operator *=()

void Geom::Trsf::operator *= ( const Trsf T)
inline

◆ power()

void Geom::Trsf::power ( const int  N)

◆ powered()

Trsf Geom::Trsf::powered ( const int  N)

Computes the following composition of transformations
<me> * <me> * .......* <me>, N time.
if N = 0 <me> = Identity
if N < 0 <me> = <me>.Inverse() *...........* <me>.Inverse().

◆ preMultiply()

void Geom::Trsf::preMultiply ( const Trsf T)

Computes the transformation composed with <me> and T.
<me> = T * <me>

◆ scaleFactor()

double Geom::Trsf::scaleFactor ( ) const

Returns the scale factor.

◆ setDisplacement()

void Geom::Trsf::setDisplacement ( const Geom::Ax3 FromSystem1,
const Geom::Ax3 ToSystem2 
)

Modifies this transformation so that it transforms the
coordinate system defined by FromSystem1 into the
one defined by ToSystem2. After this modification, this
transformation transforms:

  • the origin of FromSystem1 into the origin of ToSystem2,
  • the "X Direction" of FromSystem1 into the "X <br> Direction" of ToSystem2,
  • the "Y Direction" of FromSystem1 into the "Y <br> Direction" of ToSystem2, and
  • the "main Direction" of FromSystem1 into the "main <br> Direction" of ToSystem2.
    Warning
    When you know the coordinates of a point in one
    coordinate system and you want to express these
    coordinates in another one, do not use the
    transformation resulting from this function. Use the
    transformation that results from SetTransformation instead.
    SetDisplacement and SetTransformation create
    related transformations: the vectorial part of one is the
    inverse of the vectorial part of the other.

◆ setIdentity()

void Geom::Trsf::setIdentity ( )

Sets the transformation to identity.

◆ setMirror() [1/3]

void Geom::Trsf::setMirror ( const Geom::Pnt P)

Makes the transformation into a symmetrical transformation.
P is the center of the symmetry.

◆ setMirror() [2/3]

void Geom::Trsf::setMirror ( const Geom::Ax1 A1)

Makes the transformation into a symmetrical transformation.
A1 is the center of the axial symmetry.

◆ setMirror() [3/3]

void Geom::Trsf::setMirror ( const Geom::Ax2 A2)

Makes the transformation into a symmetrical transformation.
A2 is the center of the planar symmetry
and defines the plane of symmetry by its origin, "X <br> Direction" and "Y Direction".

◆ setRotation()

void Geom::Trsf::setRotation ( const Geom::Ax1 A1,
const double  Ang 
)

Changes the transformation into a rotation.
A1 is the rotation axis and Ang is the angular value of the
rotation in radians.

◆ setScale()

void Geom::Trsf::setScale ( const Geom::Pnt P,
const double  S 
)

Changes the transformation into a scale.
P is the center of the scale and S is the scaling value.
Raises ConstructionError If <S> is null.

◆ setScaleFactor()

void Geom::Trsf::setScaleFactor ( const double  S)

Modifies the scale factor.
Raises ConstructionError If S is null.

◆ setTransformation() [1/2]

void Geom::Trsf::setTransformation ( const Geom::Ax3 FromSystem1,
const Geom::Ax3 ToSystem2 
)

Modifies this transformation so that it transforms the
coordinates of any point, (x, y, z), relative to a source
coordinate system into the coordinates (x', y', z') which
are relative to a target coordinate system, but which
represent the same point
The transformation is from the coordinate
system "FromSystem1" to the coordinate system "ToSystem2".
Example :
In a C++ implementation :
Real x1, y1, z1; // are the coordinates of a point in the
// local system FromSystem1
Real x2, y2, z2; // are the coordinates of a point in the
// local system ToSystem2
Geom::Pnt P1 (x1, y1, z1)
Trsf T;
T.SetTransformation (FromSystem1, ToSystem2);
Geom::Pnt P2 = P1.Transformed (T);
P2.Coord (x2, y2, z2);

◆ setTransformation() [2/2]

void Geom::Trsf::setTransformation ( const Geom::Ax3 ToSystem)

Modifies this transformation so that it transforms the
coordinates of any point, (x, y, z), relative to a source
coordinate system into the coordinates (x', y', z') which
are relative to a target coordinate system, but which
represent the same point
The transformation is from the default coordinate system
{P(0.,0.,0.), VX (1.,0.,0.), VY (0.,1.,0.), VZ (0., 0. ,1.) }
to the local coordinate system defined with the Ax3 ToSystem.
Use in the same way as the previous method. FromSystem1 is
defaulted to the absolute coordinate system.

◆ setTranslation() [1/2]

void Geom::Trsf::setTranslation ( const Geom::Vec V)

Changes the transformation into a translation.
V is the vector of the translation.

◆ setTranslation() [2/2]

void Geom::Trsf::setTranslation ( const Geom::Pnt P1,
const Geom::Pnt P2 
)

Makes the transformation into a translation where the translation vector
is the vector (P1, P2) defined from point P1 to point P2.

◆ setTranslationPart()

void Geom::Trsf::setTranslationPart ( const Geom::Vec V)

Replaces the translation vector with the vector V.

◆ setValues()

void Geom::Trsf::setValues ( double  a11,
double  a12,
double  a13,
double  a14,
double  a21,
double  a22,
double  a23,
double  a24,
double  a31,
double  a32,
double  a33,
double  a34,
double  Tolang,
double  TolDist 
)

Sets the coefficients of the transformation. The
transformation of the point x,y,z is the point
x',y',z' with :

x' = a11 x + a12 y + a13 z + a14
y' = a21 x + a22 y + a23 z + a24
z' = a31 x + a32 y + a43 z + a34

Tolang and TolDist are used to test for null
angles and null distances to determine the form of
the transformation (identity, translation, etc..).

The method Value(i,j) will return aij.
Raises ConstructionError if the determinant of the aij is null. Or if
the matrix as not a uniform scale.

◆ transforms() [1/2]

void Geom::Trsf::transforms ( double &  X,
double &  Y,
double &  Z 
) const

◆ transforms() [2/2]

void Geom::Trsf::transforms ( Geom::XYZ Coord) const

Transformation of a triplet XYZ with a Trsf

◆ translate()

void Geom::Trsf::translate ( const Geom::Vec V)

Add vector V to the translation vector.

◆ translationPart()

const Geom::XYZ& Geom::Trsf::translationPart ( ) const

Returns the translation part of the transformation's matrix

◆ value()

double Geom::Trsf::value ( const int  Row,
const int  Col 
) const

Returns the coefficients of the transformation's matrix.
It is a 3 rows * 4 columns matrix.
This coefficient includes the scale factor.
Raises OutOfRanged if Row < 1 or Row > 3 or Col < 1 or Col > 4

◆ vectorialPart()

Geom::Mat Geom::Trsf::vectorialPart ( ) const

Returns the vectorial part of the transformation. It is
a 3*3 matrix which includes the scale factor.

Friends And Related Function Documentation

◆ Geom::GTrsf

friend class Geom::GTrsf
friend

◆ gp_GTrsf

friend class gp_GTrsf
friend

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