1 // Copyright (c) 1991-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 #ifndef _gp_Pnt2d_HeaderFile
16 #define _gp_Pnt2d_HeaderFile
18 #include <Standard.hxx>
19 #include <Standard_DefineAlloc.hxx>
20 #include <Standard_Handle.hxx>
23 #include <Standard_Real.hxx>
24 #include <Standard_Integer.hxx>
25 #include <Standard_Boolean.hxx>
26 class Standard_OutOfRange;
33 //! Defines a non-persistent 2D cartesian point.
41 //! Creates a point with zero coordinates.
44 //! Creates a point with a doublet of coordinates.
45 gp_Pnt2d(const gp_XY& Coord);
48 //! Creates a point with its 2 cartesian's coordinates : Xp, Yp.
49 gp_Pnt2d(const Standard_Real Xp, const Standard_Real Yp);
52 //! Assigns the value Xi to the coordinate that corresponds to Index:
53 //! Index = 1 => X is modified
54 //! Index = 2 => Y is modified
55 //! Raises OutOfRange if Index != {1, 2}.
56 void SetCoord (const Standard_Integer Index, const Standard_Real Xi);
58 //! For this point, assigns the values Xp and Yp to its two coordinates
59 void SetCoord (const Standard_Real Xp, const Standard_Real Yp);
61 //! Assigns the given value to the X coordinate of this point.
62 void SetX (const Standard_Real X);
64 //! Assigns the given value to the Y coordinate of this point.
65 void SetY (const Standard_Real Y);
67 //! Assigns the two coordinates of Coord to this point.
68 void SetXY (const gp_XY& Coord);
71 //! Returns the coordinate of range Index :
72 //! Index = 1 => X is returned
73 //! Index = 2 => Y is returned
74 //! Raises OutOfRange if Index != {1, 2}.
75 Standard_Real Coord (const Standard_Integer Index) const;
77 //! For this point returns its two coordinates as a number pair.
78 void Coord (Standard_Real& Xp, Standard_Real& Yp) const;
80 //! For this point, returns its X coordinate.
81 Standard_Real X() const;
83 //! For this point, returns its Y coordinate.
84 Standard_Real Y() const;
86 //! For this point, returns its two coordinates as a number pair.
87 const gp_XY& XY() const;
89 //! For this point, returns its two coordinates as a number pair.
90 const gp_XY& Coord() const;
93 //! Returns the coordinates of this point.
94 //! Note: This syntax allows direct modification of the returned value.
98 //! Returns True if the distance between the two
99 //! points is lower or equal to LinearTolerance.
100 Standard_Boolean IsEqual (const gp_Pnt2d& Other, const Standard_Real LinearTolerance) const;
102 //! Computes the distance between two points.
103 Standard_Real Distance (const gp_Pnt2d& Other) const;
105 //! Computes the square distance between two points.
106 Standard_Real SquareDistance (const gp_Pnt2d& Other) const;
109 //! Performs the symmetrical transformation of a point
110 //! with respect to the point P which is the center of
112 Standard_EXPORT void Mirror (const gp_Pnt2d& P);
115 //! Performs the symmetrical transformation of a point
116 //! with respect to an axis placement which is the axis
117 Standard_NODISCARD Standard_EXPORT gp_Pnt2d Mirrored (const gp_Pnt2d& P) const;
119 Standard_EXPORT void Mirror (const gp_Ax2d& A);
122 //! Rotates a point. A1 is the axis of the rotation.
123 //! Ang is the angular value of the rotation in radians.
124 Standard_NODISCARD Standard_EXPORT gp_Pnt2d Mirrored (const gp_Ax2d& A) const;
126 void Rotate (const gp_Pnt2d& P, const Standard_Real Ang);
128 //! Scales a point. S is the scaling value.
129 Standard_NODISCARD gp_Pnt2d Rotated (const gp_Pnt2d& P, const Standard_Real Ang) const;
131 void Scale (const gp_Pnt2d& P, const Standard_Real S);
133 //! Transforms a point with the transformation T.
134 Standard_NODISCARD gp_Pnt2d Scaled (const gp_Pnt2d& P, const Standard_Real S) const;
136 Standard_EXPORT void Transform (const gp_Trsf2d& T);
139 //! Translates a point in the direction of the vector V.
140 //! The magnitude of the translation is the vector's magnitude.
141 Standard_NODISCARD gp_Pnt2d Transformed (const gp_Trsf2d& T) const;
143 void Translate (const gp_Vec2d& V);
146 //! Translates a point from the point P1 to the point P2.
147 Standard_NODISCARD gp_Pnt2d Translated (const gp_Vec2d& V) const;
149 void Translate (const gp_Pnt2d& P1, const gp_Pnt2d& P2);
151 Standard_NODISCARD gp_Pnt2d Translated (const gp_Pnt2d& P1, const gp_Pnt2d& P2) const;
154 //! Dumps the content of me into the stream
155 Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
175 #include <gp_Pnt2d.lxx>
181 #endif // _gp_Pnt2d_HeaderFile