Integration of OCCT 6.5.0 from SVN
[occt.git] / src / gp / gp_Trsf.lxx
CommitLineData
7fd59977 1// File gp_Trsf.lxx, JCV 03/06/90
2// Modif JCV 04/10/90 ajout des methodes Form Scale IsNegative
3// Modif JCV 10/12/90 ajout de la methode Translationpart
4
5
6#include <Standard_OutOfRange.hxx>
7#include <gp_Trsf2d.hxx>
8#include <gp_Vec.hxx>
9#include <gp_Pnt.hxx>
10
11inline gp_Trsf::gp_Trsf () :
12scale(1.0),
13shape(gp_Identity),
14matrix(1,0,0, 0,1,0, 0,0,1),
15loc(0.0, 0.0, 0.0)
16{}
17
18inline gp_Trsf::gp_Trsf (const gp_Trsf2d& T) :
19scale(T.ScaleFactor()),
20shape(T.Form()),
21loc(T.TranslationPart().X(),T.TranslationPart().Y(), 0.0)
22{
23 const gp_Mat2d& M = T.HVectorialPart();
24 matrix(1,1) = M(1,1);
25 matrix(1,2) = M(1,2);
26 matrix(2,1) = M(2,1);
27 matrix(2,2) = M(2,2);
28 matrix(3,3) = 1.;
29}
30
31inline void gp_Trsf::SetMirror (const gp_Pnt& P)
32{
33 shape = gp_PntMirror;
34 scale = -1.0;
35 loc = P.XYZ();
36 matrix.SetIdentity ();
37 loc.Multiply(2.0);
38}
39
40inline void gp_Trsf::SetTranslation (const gp_Vec& V)
41{
42 shape = gp_Translation;
43 scale = 1.;
44 matrix.SetIdentity ();
45 loc = V.XYZ();
46}
47
48inline void gp_Trsf::SetTranslation(const gp_Pnt& P1,
49 const gp_Pnt& P2)
50{
51 shape = gp_Translation;
52 scale = 1.0;
53 matrix.SetIdentity ();
54 loc = (P2.XYZ()).Subtracted (P1.XYZ());
55}
56
57inline Standard_Boolean gp_Trsf::IsNegative() const
58{ return (scale < 0.0); }
59
60inline const gp_XYZ& gp_Trsf::TranslationPart () const
61{ return loc; }
62
63inline const gp_Mat& gp_Trsf::HVectorialPart () const
64{ return matrix; }
65
66inline Standard_Real gp_Trsf::Value (const Standard_Integer Row,
67 const Standard_Integer Col) const
68{
69 Standard_OutOfRange_Raise_if
70 (Row < 1 || Row > 3 || Col < 1 || Col > 4, " ");
71 if (Col < 4) return scale * matrix.Value (Row, Col);
72 else return loc.Coord (Row);
73}
74
75inline gp_TrsfForm gp_Trsf::Form () const
76{ return shape; }
77
78inline Standard_Real gp_Trsf::ScaleFactor () const
79{ return scale; }
80
81inline gp_Trsf gp_Trsf::Inverted() const
82{
83 gp_Trsf T = *this;
84 T.Invert();
85 return T;
86}
87
88inline gp_Trsf gp_Trsf::Multiplied (const gp_Trsf& T) const
89{
90 gp_Trsf Tresult(*this);
91 Tresult.Multiply(T);
92 return Tresult;
93}
94
95inline gp_Trsf gp_Trsf::Powered (const Standard_Integer N)
96{
97 gp_Trsf T = *this;
98 T.Power (N);
99 return T;
100}
101
102inline void gp_Trsf::Transforms (Standard_Real& X,
103 Standard_Real& Y,
104 Standard_Real& Z) const
105{
106 gp_XYZ Triplet (X, Y, Z);
107 Triplet.Multiply (matrix);
108 if (scale != 1.0) Triplet.Multiply (scale);
109 Triplet.Add(loc);
110 X = Triplet.X();
111 Y = Triplet.Y();
112 Z = Triplet.Z();
113}
114
115inline void gp_Trsf::Transforms (gp_XYZ& Coord) const
116{
117 Coord.Multiply (matrix);
118 if (scale != 1.0) Coord.Multiply (scale);
119 Coord.Add(loc);
120}
121