// Copyright (c) 1995-1999 Matra Datavision // Copyright (c) 1999-2014 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // // This library is free software; you can redistribute it and/or modify it under // the terms of the GNU Lesser General Public License version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. // // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. // Modif JCV 08/01/91 modifs suite a la deuxieme revue de projet // et introduction des classes XY, Mat2d. // Modif DPF 23/06/93 Ajout fonction Coord pour genericite 2d 3d #include #include #include inline gp_Pnt2d::gp_Pnt2d (const gp_XY& Coordinates) : coord (Coordinates) { } inline gp_Pnt2d::gp_Pnt2d (const Standard_Real Xp, const Standard_Real Yp) : coord (Xp, Yp) { } inline gp_Pnt2d::gp_Pnt2d() { } inline Standard_Real gp_Pnt2d::Coord(const Standard_Integer Index) const { return coord.Coord(Index); } inline void gp_Pnt2d::SetX (const Standard_Real X) { coord.SetX (X); } inline void gp_Pnt2d::SetY (const Standard_Real Y) { coord.SetY (Y); } inline void gp_Pnt2d::SetXY (const gp_XY& Coordinates) { coord = Coordinates; } inline void gp_Pnt2d::SetCoord (const Standard_Real Xp, const Standard_Real Yp) { coord.SetCoord (Xp, Yp);} inline void gp_Pnt2d::SetCoord (const Standard_Integer Index, const Standard_Real Xi) { coord.SetCoord (Index, Xi); } inline void gp_Pnt2d::Coord (Standard_Real& Xp, Standard_Real& Yp) const { coord.Coord (Xp, Yp); } inline Standard_Real gp_Pnt2d::X() const { return coord.X(); } inline Standard_Real gp_Pnt2d::Y() const { return coord.Y(); } inline const gp_XY& gp_Pnt2d::XY () const { return coord; } inline const gp_XY& gp_Pnt2d::Coord () const { return coord; } inline gp_XY& gp_Pnt2d::ChangeCoord () { return coord; } inline Standard_Boolean gp_Pnt2d::IsEqual (const gp_Pnt2d& Other, const Standard_Real LinearTolerance) const { return Distance (Other) <= LinearTolerance; } inline Standard_Real gp_Pnt2d::Distance (const gp_Pnt2d& Other) const { const gp_XY& XY = Other.coord; Standard_Real X = coord.X() - XY.X(); Standard_Real Y = coord.Y() - XY.Y(); return sqrt (X * X + Y * Y); } inline Standard_Real gp_Pnt2d::SquareDistance (const gp_Pnt2d& Other) const { const gp_XY& XY = Other.coord; Standard_Real X = coord.X() - XY.X(); Standard_Real Y = coord.Y() - XY.Y(); return (X * X + Y * Y); } inline void gp_Pnt2d::Rotate (const gp_Pnt2d& P, const Standard_Real Ang) { gp_Trsf2d T; T.SetRotation (P, Ang); T.Transforms (coord); } inline gp_Pnt2d gp_Pnt2d::Rotated (const gp_Pnt2d& P, const Standard_Real Ang) const { gp_Pnt2d Pres = *this; Pres.Rotate (P, Ang); return Pres; } inline void gp_Pnt2d::Scale (const gp_Pnt2d& P, const Standard_Real S) { gp_XY XY = P.coord; XY.Multiply (1.0 - S); coord.Multiply (S); coord.Add (XY); } inline gp_Pnt2d gp_Pnt2d::Scaled (const gp_Pnt2d& P, const Standard_Real S) const { gp_Pnt2d Pres = *this; Pres.Scale (P, S); return Pres; } inline gp_Pnt2d gp_Pnt2d::Transformed (const gp_Trsf2d& T) const { gp_Pnt2d Pres = *this; Pres.Transform (T); return Pres; } inline void gp_Pnt2d::Translate (const gp_Vec2d& V) { coord.Add (V.XY()); } inline gp_Pnt2d gp_Pnt2d::Translated (const gp_Vec2d& V) const { gp_Pnt2d P = *this; P.coord.Add (V.XY ()); return P; } inline void gp_Pnt2d::Translate (const gp_Pnt2d& P1, const gp_Pnt2d& P2) { coord.Add (P2.coord); coord.Subtract (P1.coord); } inline gp_Pnt2d gp_Pnt2d::Translated (const gp_Pnt2d& P1, const gp_Pnt2d& P2) const { gp_Pnt2d P = *this; P.Translate (P1, P2); return P; }