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