1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #include <gp_Trsf.hxx>
16 #include <gp_Pnt2d.hxx>
18 inline gp_Trsf2d::gp_Trsf2d () {
21 matrix.SetIdentity ();
22 loc.SetCoord (0.0, 0.0);
25 inline gp_Trsf2d::gp_Trsf2d (const gp_Trsf& T) :
26 scale(T.ScaleFactor()),
28 loc(T.TranslationPart().X(),T.TranslationPart().Y())
30 const gp_Mat& M = T.HVectorialPart();
37 inline void gp_Trsf2d::SetMirror(const gp_Pnt2d& P)
41 matrix.SetIdentity ();
46 inline void gp_Trsf2d::SetRotation (const gp_Pnt2d& P,
47 const Standard_Real Ang)
53 matrix.SetRotation (Ang);
54 loc.Multiply (matrix);
58 inline void gp_Trsf2d::SetScale (const gp_Pnt2d& P,
59 const Standard_Real S)
63 matrix.SetIdentity ();
65 loc.Multiply (1.0 - S);
68 inline void gp_Trsf2d::SetTranslation(const gp_Vec2d& V)
70 shape = gp_Translation;
72 matrix.SetIdentity ();
76 inline void gp_Trsf2d::SetTranslation (const gp_Pnt2d& P1,
79 shape = gp_Translation;
81 matrix.SetIdentity ();
82 loc = (P2.XY()).Subtracted (P1.XY());
85 inline Standard_Boolean gp_Trsf2d::IsNegative() const
86 { return (matrix.Determinant() < 0.0); }
88 inline const gp_XY& gp_Trsf2d::TranslationPart () const
91 inline const gp_Mat2d& gp_Trsf2d::HVectorialPart () const
94 inline Standard_Real gp_Trsf2d::Value (const Standard_Integer Row,
95 const Standard_Integer Col) const
97 Standard_OutOfRange_Raise_if
98 (Row < 1 || Row > 2 || Col < 1 || Col > 3, " ");
99 if (Col < 3) return scale * matrix.Value (Row, Col);
100 else return loc.Coord (Row);
103 inline gp_TrsfForm gp_Trsf2d::Form() const
106 inline Standard_Real gp_Trsf2d::ScaleFactor() const
109 inline gp_Trsf2d gp_Trsf2d::Inverted() const
116 inline gp_Trsf2d gp_Trsf2d::Multiplied (const gp_Trsf2d& T) const {
117 gp_Trsf2d Tresult(*this);
122 inline gp_Trsf2d gp_Trsf2d::Powered (const Standard_Integer N)
129 inline void gp_Trsf2d::Transforms (Standard_Real& X,
130 Standard_Real& Y) const
132 gp_XY Doublet (X, Y);
133 Doublet.Multiply (matrix);
134 if (scale != 1.0) Doublet.Multiply (scale);
136 Doublet.Coord (X, Y);
139 inline void gp_Trsf2d::Transforms (gp_XY& Coord) const
141 Coord.Multiply (matrix);
142 if (scale != 1.0) Coord.Multiply (scale);