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 // JCV 30/08/90 Modif passage version C++ 2.0 sur Sun
16 // JCV 06/12/90 Modif introduction des classes XYZ Mat dans le package gp
17 // Modif DPF 23/06/93 Ajout fonction Coord pour genericite 2d 3d
19 #include <gp_Trsf.hxx>
22 inline gp_Pnt::gp_Pnt() { }
24 inline gp_Pnt::gp_Pnt (const gp_XYZ& Coordinates) : coord (Coordinates)
27 inline gp_Pnt::gp_Pnt (const Standard_Real Xp,
28 const Standard_Real Yp,
29 const Standard_Real Zp) : coord(Xp, Yp,Zp)
32 inline void gp_Pnt::SetCoord (const Standard_Integer Index,
33 const Standard_Real Xi)
34 { coord.SetCoord (Index, Xi); }
36 inline void gp_Pnt::SetCoord (const Standard_Real Xp,
37 const Standard_Real Yp,
38 const Standard_Real Zp) {
39 coord.SetCoord (Xp, Yp, Zp);
42 inline void gp_Pnt::SetX (const Standard_Real X)
45 inline void gp_Pnt::SetY (const Standard_Real Y)
48 inline void gp_Pnt::SetZ (const Standard_Real Z)
51 inline void gp_Pnt::SetXYZ (const gp_XYZ& Coordinates)
52 { coord = Coordinates; }
54 inline Standard_Real gp_Pnt::Coord (const Standard_Integer Index) const
55 { return coord.Coord(Index); }
57 inline void gp_Pnt::Coord (Standard_Real& Xp,
59 Standard_Real& Zp) const {
60 coord.Coord (Xp, Yp, Zp);
63 inline Standard_Real gp_Pnt::X() const
66 inline Standard_Real gp_Pnt::Y() const
69 inline Standard_Real gp_Pnt::Z() const
72 inline const gp_XYZ& gp_Pnt::XYZ () const
75 inline const gp_XYZ& gp_Pnt::Coord () const
78 inline gp_XYZ& gp_Pnt::ChangeCoord ()
81 inline void gp_Pnt::BaryCenter(const Standard_Real A,
83 const Standard_Real B)
85 coord.SetLinearForm(A,coord,B,P.coord);
89 inline Standard_Boolean gp_Pnt::IsEqual
91 const Standard_Real LinearTolerance) const
92 { return Distance (Other) <= LinearTolerance; }
94 inline Standard_Real gp_Pnt::Distance (const gp_Pnt& Other) const
97 const gp_XYZ& XYZ = Other.coord;
98 dd = coord.X(); dd -= XYZ.X(); dd *= dd; d += dd;
99 dd = coord.Y(); dd -= XYZ.Y(); dd *= dd; d += dd;
100 dd = coord.Z(); dd -= XYZ.Z(); dd *= dd; d += dd;
104 inline Standard_Real gp_Pnt::SquareDistance (const gp_Pnt& Other) const
106 Standard_Real d=0,dd;
107 const gp_XYZ& XYZ = Other.coord;
108 dd = coord.X(); dd -= XYZ.X(); dd *= dd; d += dd;
109 dd = coord.Y(); dd -= XYZ.Y(); dd *= dd; d += dd;
110 dd = coord.Z(); dd -= XYZ.Z(); dd *= dd; d += dd;
114 inline void gp_Pnt::Rotate (const gp_Ax1& A1,
115 const Standard_Real Ang)
118 T.SetRotation (A1, Ang);
119 T.Transforms (coord);
122 inline gp_Pnt gp_Pnt::Rotated (const gp_Ax1& A1,
123 const Standard_Real Ang) const
130 inline void gp_Pnt::Scale (const gp_Pnt& P,
131 const Standard_Real S)
133 gp_XYZ XYZ = P.coord;
134 XYZ.Multiply (1.0 - S);
139 inline gp_Pnt gp_Pnt::Scaled (const gp_Pnt& P,
140 const Standard_Real S) const
147 inline gp_Pnt gp_Pnt::Transformed (const gp_Trsf& T) const
154 inline void gp_Pnt::Translate (const gp_Vec& V)
155 { coord.Add (V.XYZ()); }
157 inline gp_Pnt gp_Pnt::Translated (const gp_Vec& V) const
160 P.coord.Add (V.XYZ());
164 inline void gp_Pnt::Translate (const gp_Pnt& P1,
167 coord.Add (P2.coord);
168 coord.Subtract (P1.coord);
171 inline gp_Pnt gp_Pnt::Translated (const gp_Pnt& P1,
172 const gp_Pnt& P2) const
175 P.Translate (P1 , P2);