Salome HOME
f39d78acac8f9750798869ee6da9e5dc23c8169b
[modules/geom.git] / src / GEOMUtils / GEOMUtils_Trsf2d.cxx
1 // Copyright (C) 2015-2023  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20
21 #include <GEOMUtils_Trsf2d.hxx>
22
23
24 //=======================================================================
25 //function : Trsf2d
26 //purpose  :
27 //=======================================================================
28 GEOMUtils::Trsf2d::Trsf2d(const Standard_Real a11,
29                           const Standard_Real a12,
30                           const Standard_Real a13,
31                           const Standard_Real a21,
32                           const Standard_Real a22,
33                           const Standard_Real a23)
34 : myA11(a11),
35   myA12(a12),
36   myA13(a13),
37   myA21(a21),
38   myA22(a22),
39   myA23(a23)
40 {
41 }
42
43 //=======================================================================
44 //function : TransformD0
45 //purpose  :
46 //=======================================================================
47 void GEOMUtils::Trsf2d::TransformD0(gp_Pnt2d &thePnt) const
48 {
49   const Standard_Real aX = myA11*thePnt.X() + myA12*thePnt.Y() + myA13;
50   const Standard_Real aY = myA21*thePnt.X() + myA22*thePnt.Y() + myA23;
51
52   thePnt.SetCoord(aX, aY);
53 }
54
55 //=======================================================================
56 //function : TransformD1
57 //purpose  :
58 //=======================================================================
59 void GEOMUtils::Trsf2d::TransformD1(gp_Pnt2d &thePnt,
60                                     gp_Vec2d &theVec1) const
61 {
62   TransformVector(thePnt, theVec1);
63   TransformD0(thePnt);
64 }
65
66 //=======================================================================
67 //function : TransformD2
68 //purpose  :
69 //=======================================================================
70 void GEOMUtils::Trsf2d::TransformD2(gp_Pnt2d &thePnt,
71                                     gp_Vec2d &theVec1,
72                                     gp_Vec2d &theVec2) const
73 {
74   TransformVector(thePnt, theVec1);
75   TransformVector(thePnt, theVec2);
76   TransformD0(thePnt);
77 }
78
79 //=======================================================================
80 //function : TransformD3
81 //purpose  :
82 //=======================================================================
83 void GEOMUtils::Trsf2d::TransformD3(gp_Pnt2d &thePnt,
84                                     gp_Vec2d &theVec1,
85                                     gp_Vec2d &theVec2,
86                                     gp_Vec2d &theVec3) const
87 {
88   TransformVector(thePnt, theVec1);
89   TransformVector(thePnt, theVec2);
90   TransformVector(thePnt, theVec3);
91   TransformD0(thePnt);
92 }
93
94 //=======================================================================
95 //function : TransformVector
96 //purpose  :
97 //=======================================================================
98 void GEOMUtils::Trsf2d::TransformVector(const gp_Pnt2d &thePnt,
99                                               gp_Vec2d &theVec) const
100 {
101   gp_Pnt2d aP0(thePnt.XY());
102   gp_Pnt2d aP1(thePnt.XY().Added(theVec.XY()));
103
104   TransformD0(aP0);
105   TransformD0(aP1);
106   theVec.SetXY(aP1.XY().Subtracted(aP0.XY()));
107 }