0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / gp / gp_Pnt.lxx
CommitLineData
b311480e 1// Copyright (c) 1995-1999 Matra Datavision
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
b311480e 5//
d5f74e42 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
973c2be1 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.
b311480e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
b311480e 14
7fd59977 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
18
19#include <gp_Trsf.hxx>
20#include <gp_Vec.hxx>
21
22inline gp_Pnt::gp_Pnt() { }
23
24inline gp_Pnt::gp_Pnt (const gp_XYZ& Coordinates) : coord (Coordinates)
25{ }
26
27inline gp_Pnt::gp_Pnt (const Standard_Real Xp,
28 const Standard_Real Yp,
29 const Standard_Real Zp) : coord(Xp, Yp,Zp)
30{ }
31
32inline void gp_Pnt::SetCoord (const Standard_Integer Index,
33 const Standard_Real Xi)
34{ coord.SetCoord (Index, Xi); }
35
36inline void gp_Pnt::SetCoord (const Standard_Real Xp,
37 const Standard_Real Yp,
38 const Standard_Real Zp) {
39 coord.SetCoord (Xp, Yp, Zp);
40}
41
42inline void gp_Pnt::SetX (const Standard_Real X)
43{ coord.SetX (X); }
44
45inline void gp_Pnt::SetY (const Standard_Real Y)
46{ coord.SetY (Y); }
47
48inline void gp_Pnt::SetZ (const Standard_Real Z)
49{ coord.SetZ (Z); }
50
51inline void gp_Pnt::SetXYZ (const gp_XYZ& Coordinates)
52{ coord = Coordinates; }
53
54inline Standard_Real gp_Pnt::Coord (const Standard_Integer Index) const
55{ return coord.Coord(Index); }
56
57inline void gp_Pnt::Coord (Standard_Real& Xp,
58 Standard_Real& Yp,
59 Standard_Real& Zp) const {
60 coord.Coord (Xp, Yp, Zp);
61 }
62
63inline Standard_Real gp_Pnt::X() const
64{ return coord.X(); }
65
66inline Standard_Real gp_Pnt::Y() const
67{ return coord.Y(); }
68
69inline Standard_Real gp_Pnt::Z() const
70{ return coord.Z(); }
71
72inline const gp_XYZ& gp_Pnt::XYZ () const
73{ return coord; }
74
75inline const gp_XYZ& gp_Pnt::Coord () const
76{ return coord; }
77
78inline gp_XYZ& gp_Pnt::ChangeCoord ()
79{ return coord; }
80
81inline void gp_Pnt::BaryCenter(const Standard_Real A,
82 const gp_Pnt& P,
83 const Standard_Real B)
84{
85 coord.SetLinearForm(A,coord,B,P.coord);
86 coord.Divide(A + B);
87}
88
89inline Standard_Boolean gp_Pnt::IsEqual
90(const gp_Pnt& Other,
91 const Standard_Real LinearTolerance) const
92{ return Distance (Other) <= LinearTolerance; }
93
94inline Standard_Real gp_Pnt::Distance (const gp_Pnt& Other) const
95{
96 Standard_Real d=0,dd;
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;
101 return(sqrt(d));
102}
103
104inline Standard_Real gp_Pnt::SquareDistance (const gp_Pnt& Other) const
105{
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;
111 return(d);
112}
113
114inline void gp_Pnt::Rotate (const gp_Ax1& A1,
115 const Standard_Real Ang)
116{
117 gp_Trsf T;
118 T.SetRotation (A1, Ang);
119 T.Transforms (coord);
120}
121
122inline gp_Pnt gp_Pnt::Rotated (const gp_Ax1& A1,
123 const Standard_Real Ang) const
124{
125 gp_Pnt P = *this;
126 P.Rotate (A1, Ang);
127 return P;
128}
129
130inline void gp_Pnt::Scale (const gp_Pnt& P,
131 const Standard_Real S)
132{
133 gp_XYZ XYZ = P.coord;
134 XYZ.Multiply (1.0 - S);
135 coord.Multiply (S);
136 coord.Add (XYZ);
137}
138
139inline gp_Pnt gp_Pnt::Scaled (const gp_Pnt& P,
140 const Standard_Real S) const
141{
142 gp_Pnt Pres = *this;
143 Pres.Scale (P, S);
144 return Pres;
145}
146
147inline gp_Pnt gp_Pnt::Transformed (const gp_Trsf& T) const
148{
149 gp_Pnt P = *this;
150 P.Transform (T);
151 return P;
152}
153
154inline void gp_Pnt::Translate (const gp_Vec& V)
155{ coord.Add (V.XYZ()); }
156
157inline gp_Pnt gp_Pnt::Translated (const gp_Vec& V) const
158{
159 gp_Pnt P = *this;
160 P.coord.Add (V.XYZ());
161 return P;
162}
163
164inline void gp_Pnt::Translate (const gp_Pnt& P1,
165 const gp_Pnt& P2)
166{
167 coord.Add (P2.coord);
168 coord.Subtract (P1.coord);
169}
170
171inline gp_Pnt gp_Pnt::Translated (const gp_Pnt& P1,
172 const gp_Pnt& P2) const
173{
174 gp_Pnt P = *this;
175 P.Translate (P1 , P2);
176 return P;
177}
178