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_Pnt_HeaderFile
16 #define _gp_Pnt_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;
34 //! Defines a 3D cartesian point.
42 //! Creates a point with zero coordinates.
45 //! Creates a point from a XYZ object.
46 gp_Pnt(const gp_XYZ& Coord);
49 //! Creates a point with its 3 cartesian's coordinates : Xp, Yp, Zp.
50 gp_Pnt(const Standard_Real Xp, const Standard_Real Yp, const Standard_Real Zp);
53 //! Changes the coordinate of range Index :
54 //! Index = 1 => X is modified
55 //! Index = 2 => Y is modified
56 //! Index = 3 => Z is modified
57 //! Raised if Index != {1, 2, 3}.
58 void SetCoord (const Standard_Integer Index, const Standard_Real Xi);
60 //! For this point, assigns the values Xp, Yp and Zp to its three coordinates.
61 void SetCoord (const Standard_Real Xp, const Standard_Real Yp, const Standard_Real Zp);
63 //! Assigns the given value to the X coordinate of this point.
64 void SetX (const Standard_Real X);
66 //! Assigns the given value to the Y coordinate of this point.
67 void SetY (const Standard_Real Y);
69 //! Assigns the given value to the Z coordinate of this point.
70 void SetZ (const Standard_Real Z);
72 //! Assigns the three coordinates of Coord to this point.
73 void SetXYZ (const gp_XYZ& Coord);
76 //! Returns the coordinate of corresponding to the value of Index :
77 //! Index = 1 => X is returned
78 //! Index = 2 => Y is returned
79 //! Index = 3 => Z is returned
80 //! Raises OutOfRange if Index != {1, 2, 3}.
81 //! Raised if Index != {1, 2, 3}.
82 Standard_Real Coord (const Standard_Integer Index) const;
84 //! For this point gives its three coordinates Xp, Yp and Zp.
85 void Coord (Standard_Real& Xp, Standard_Real& Yp, Standard_Real& Zp) const;
87 //! For this point, returns its X coordinate.
88 Standard_Real X() const;
90 //! For this point, returns its Y coordinate.
91 Standard_Real Y() const;
93 //! For this point, returns its Z coordinate.
94 Standard_Real Z() const;
96 //! For this point, returns its three coordinates as a XYZ object.
97 const gp_XYZ& XYZ() const;
99 //! For this point, returns its three coordinates as a XYZ object.
100 const gp_XYZ& Coord() const;
103 //! Returns the coordinates of this point.
104 //! Note: This syntax allows direct modification of the returned value.
105 gp_XYZ& ChangeCoord();
107 //! Assigns the result of the following expression to this point
108 //! (Alpha*this + Beta*P) / (Alpha + Beta)
109 void BaryCenter (const Standard_Real Alpha, const gp_Pnt& P, const Standard_Real Beta);
112 //! Returns True if the distance between the two points is
113 //! lower or equal to LinearTolerance.
114 Standard_Boolean IsEqual (const gp_Pnt& Other, const Standard_Real LinearTolerance) const;
116 //! Computes the distance between two points.
117 Standard_Real Distance (const gp_Pnt& Other) const;
119 //! Computes the square distance between two points.
120 Standard_Real SquareDistance (const gp_Pnt& Other) const;
123 //! Performs the symmetrical transformation of a point
124 //! with respect to the point P which is the center of
126 Standard_EXPORT void Mirror (const gp_Pnt& P);
129 //! Performs the symmetrical transformation of a point
130 //! with respect to an axis placement which is the axis
132 Standard_EXPORT gp_Pnt Mirrored (const gp_Pnt& P) const;
134 Standard_EXPORT void Mirror (const gp_Ax1& A1);
137 //! Performs the symmetrical transformation of a point
138 //! with respect to a plane. The axis placement A2 locates
139 //! the plane of the symmetry : (Location, XDirection, YDirection).
140 Standard_EXPORT gp_Pnt Mirrored (const gp_Ax1& A1) const;
142 Standard_EXPORT void Mirror (const gp_Ax2& A2);
145 //! Rotates a point. A1 is the axis of the rotation.
146 //! Ang is the angular value of the rotation in radians.
147 Standard_EXPORT gp_Pnt Mirrored (const gp_Ax2& A2) const;
149 void Rotate (const gp_Ax1& A1, const Standard_Real Ang);
151 //! Scales a point. S is the scaling value.
152 gp_Pnt Rotated (const gp_Ax1& A1, const Standard_Real Ang) const;
154 void Scale (const gp_Pnt& P, const Standard_Real S);
156 //! Transforms a point with the transformation T.
157 gp_Pnt Scaled (const gp_Pnt& P, const Standard_Real S) const;
159 Standard_EXPORT void Transform (const gp_Trsf& T);
162 //! Translates a point in the direction of the vector V.
163 //! The magnitude of the translation is the vector's magnitude.
164 gp_Pnt Transformed (const gp_Trsf& T) const;
166 void Translate (const gp_Vec& V);
169 //! Translates a point from the point P1 to the point P2.
170 gp_Pnt Translated (const gp_Vec& V) const;
172 void Translate (const gp_Pnt& P1, const gp_Pnt& P2);
174 gp_Pnt Translated (const gp_Pnt& P1, const gp_Pnt& P2) const;
195 #include <gp_Pnt.lxx>
201 #endif // _gp_Pnt_HeaderFile