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_Trsf2d.hxx>
16 #include <Standard_OutOfRange.hxx>
18 inline gp_GTrsf2d::gp_GTrsf2d ()
21 matrix.SetScale (1.0);
22 loc.SetCoord (0.0, 0.0);
26 inline gp_GTrsf2d::gp_GTrsf2d (const gp_Trsf2d& T)
34 inline gp_GTrsf2d::gp_GTrsf2d (const gp_Mat2d& M,
38 { shape = gp_Other; scale = 0.0; }
40 inline void gp_GTrsf2d::SetValue (const Standard_Integer Row,
41 const Standard_Integer Col,
42 const Standard_Real Value)
44 Standard_OutOfRange_Raise_if
45 (Row < 1 || Row > 2 || Col < 1 || Col > 3, " ");
46 if (Col == 3) loc.SetCoord (Row, Value);
47 else matrix.SetValue (Row, Col, Value);
51 inline void gp_GTrsf2d::SetTrsf2d (const gp_Trsf2d& T)
59 inline void gp_GTrsf2d::SetVectorialPart (const gp_Mat2d& Matrix)
60 { matrix = Matrix; shape = gp_Other; scale = 0.0; }
62 inline Standard_Boolean gp_GTrsf2d::IsNegative () const
63 { return matrix.Determinant() < 0.0; }
65 inline Standard_Boolean gp_GTrsf2d::IsSingular () const
66 { return matrix.IsSingular(); }
68 inline const gp_Mat2d& gp_GTrsf2d::VectorialPart () const
71 inline Standard_Real gp_GTrsf2d::Value (const Standard_Integer Row,
72 const Standard_Integer Col) const
74 Standard_OutOfRange_Raise_if
75 (Row < 1 || Row > 2 || Col < 1 || Col > 3, " ");
76 if (Col == 3) return loc.Coord (Row);
77 if (shape == gp_Other) return matrix.Value (Row, Col);
78 return scale * matrix.Value (Row, Col);
81 inline gp_TrsfForm gp_GTrsf2d::Form () const
84 inline const gp_XY& gp_GTrsf2d::TranslationPart () const
87 inline gp_GTrsf2d gp_GTrsf2d::Inverted () const
94 inline gp_GTrsf2d gp_GTrsf2d::Multiplied (const gp_GTrsf2d& T) const
96 gp_GTrsf2d Tres = *this;
101 inline gp_GTrsf2d gp_GTrsf2d::Powered (const Standard_Integer N) const
103 gp_GTrsf2d T = *this;
108 inline void gp_GTrsf2d::Transforms (gp_XY& Coord) const
110 Coord.Multiply (matrix);
111 if (!(shape == gp_Other) && !(scale == 1.0)) Coord.Multiply (scale);
115 inline gp_XY gp_GTrsf2d::Transformed(const gp_XY& Coord) const
117 gp_XY newCoord = Coord;
118 Transforms(newCoord);
122 inline void gp_GTrsf2d::Transforms (Standard_Real& X,
123 Standard_Real& Y) const
125 gp_XY Doublet (X, Y);
126 Doublet.Multiply (matrix);
127 if (!(shape == gp_Other) && !(scale == 1.0)) Doublet.Multiply (scale);
129 Doublet.Coord (X, Y);