1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
19 // Modif JCV 08/01/91 modifs suite a la deuxieme revue de projet
20 // et introduction des classes XY, Mat2d.
21 // Modif DPF 23/06/93 Ajout fonction Coord pour genericite 2d 3d
23 #include <gp_Vec2d.hxx>
24 #include <gp_Ax2d.hxx>
25 #include <gp_Trsf2d.hxx>
27 inline gp_Pnt2d::gp_Pnt2d (const gp_XY& Coordinates) : coord (Coordinates)
30 inline gp_Pnt2d::gp_Pnt2d (const Standard_Real Xp,
31 const Standard_Real Yp) : coord (Xp, Yp)
34 inline gp_Pnt2d::gp_Pnt2d() { }
36 inline Standard_Real gp_Pnt2d::Coord(const Standard_Integer Index) const { return coord.Coord(Index); }
38 inline void gp_Pnt2d::SetX (const Standard_Real X)
41 inline void gp_Pnt2d::SetY (const Standard_Real Y)
44 inline void gp_Pnt2d::SetXY (const gp_XY& Coordinates)
45 { coord = Coordinates; }
47 inline void gp_Pnt2d::SetCoord (const Standard_Real Xp,
48 const Standard_Real Yp)
49 { coord.SetCoord (Xp, Yp);}
51 inline void gp_Pnt2d::SetCoord (const Standard_Integer Index,
52 const Standard_Real Xi)
53 { coord.SetCoord (Index, Xi); }
55 inline void gp_Pnt2d::Coord (Standard_Real& Xp,
56 Standard_Real& Yp) const
57 { coord.Coord (Xp, Yp); }
59 inline Standard_Real gp_Pnt2d::X() const
62 inline Standard_Real gp_Pnt2d::Y() const
65 inline const gp_XY& gp_Pnt2d::XY () const
68 inline const gp_XY& gp_Pnt2d::Coord () const
71 inline gp_XY& gp_Pnt2d::ChangeCoord ()
74 inline Standard_Boolean gp_Pnt2d::IsEqual
75 (const gp_Pnt2d& Other,
76 const Standard_Real LinearTolerance) const
77 { return Distance (Other) <= LinearTolerance; }
79 inline Standard_Real gp_Pnt2d::Distance (const gp_Pnt2d& Other) const
81 const gp_XY& XY = Other.coord;
82 Standard_Real X = coord.X() - XY.X();
83 Standard_Real Y = coord.Y() - XY.Y();
84 return sqrt (X * X + Y * Y);
87 inline Standard_Real gp_Pnt2d::SquareDistance (const gp_Pnt2d& Other) const
89 const gp_XY& XY = Other.coord;
90 Standard_Real X = coord.X() - XY.X();
91 Standard_Real Y = coord.Y() - XY.Y();
92 return (X * X + Y * Y);
95 inline void gp_Pnt2d::Rotate (const gp_Pnt2d& P,
96 const Standard_Real Ang)
99 T.SetRotation (P, Ang);
100 T.Transforms (coord);
103 inline gp_Pnt2d gp_Pnt2d::Rotated (const gp_Pnt2d& P,
104 const Standard_Real Ang) const
106 gp_Pnt2d Pres = *this;
107 Pres.Rotate (P, Ang);
111 inline void gp_Pnt2d::Scale (const gp_Pnt2d& P,
112 const Standard_Real S)
115 XY.Multiply (1.0 - S);
120 inline gp_Pnt2d gp_Pnt2d::Scaled (const gp_Pnt2d& P,
121 const Standard_Real S) const
123 gp_Pnt2d Pres = *this;
128 inline gp_Pnt2d gp_Pnt2d::Transformed (const gp_Trsf2d& T) const
130 gp_Pnt2d Pres = *this;
135 inline void gp_Pnt2d::Translate (const gp_Vec2d& V)
136 { coord.Add (V.XY()); }
138 inline gp_Pnt2d gp_Pnt2d::Translated (const gp_Vec2d& V) const
141 P.coord.Add (V.XY ());
145 inline void gp_Pnt2d::Translate (const gp_Pnt2d& P1,
148 coord.Add (P2.coord);
149 coord.Subtract (P1.coord);
152 inline gp_Pnt2d gp_Pnt2d::Translated (const gp_Pnt2d& P1,
153 const gp_Pnt2d& P2) const
156 P.Translate (P1, P2);