Integration of OCCT 6.5.0 from SVN
[occt.git] / src / gp / gp_Pnt.lxx
CommitLineData
7fd59977 1// File gp_Pnt.lxx , JCV 03/06/90
2// JCV 30/08/90 Modif passage version C++ 2.0 sur Sun
3// JCV 06/12/90 Modif introduction des classes XYZ Mat dans le package gp
4// Modif DPF 23/06/93 Ajout fonction Coord pour genericite 2d 3d
5
6#include <gp_Trsf.hxx>
7#include <gp_Vec.hxx>
8
9inline gp_Pnt::gp_Pnt() { }
10
11inline gp_Pnt::gp_Pnt (const gp_XYZ& Coordinates) : coord (Coordinates)
12{ }
13
14inline gp_Pnt::gp_Pnt (const Standard_Real Xp,
15 const Standard_Real Yp,
16 const Standard_Real Zp) : coord(Xp, Yp,Zp)
17{ }
18
19inline void gp_Pnt::SetCoord (const Standard_Integer Index,
20 const Standard_Real Xi)
21{ coord.SetCoord (Index, Xi); }
22
23inline void gp_Pnt::SetCoord (const Standard_Real Xp,
24 const Standard_Real Yp,
25 const Standard_Real Zp) {
26 coord.SetCoord (Xp, Yp, Zp);
27}
28
29inline void gp_Pnt::SetX (const Standard_Real X)
30{ coord.SetX (X); }
31
32inline void gp_Pnt::SetY (const Standard_Real Y)
33{ coord.SetY (Y); }
34
35inline void gp_Pnt::SetZ (const Standard_Real Z)
36{ coord.SetZ (Z); }
37
38inline void gp_Pnt::SetXYZ (const gp_XYZ& Coordinates)
39{ coord = Coordinates; }
40
41inline Standard_Real gp_Pnt::Coord (const Standard_Integer Index) const
42{ return coord.Coord(Index); }
43
44inline void gp_Pnt::Coord (Standard_Real& Xp,
45 Standard_Real& Yp,
46 Standard_Real& Zp) const {
47 coord.Coord (Xp, Yp, Zp);
48 }
49
50inline Standard_Real gp_Pnt::X() const
51{ return coord.X(); }
52
53inline Standard_Real gp_Pnt::Y() const
54{ return coord.Y(); }
55
56inline Standard_Real gp_Pnt::Z() const
57{ return coord.Z(); }
58
59inline const gp_XYZ& gp_Pnt::XYZ () const
60{ return coord; }
61
62inline const gp_XYZ& gp_Pnt::Coord () const
63{ return coord; }
64
65inline gp_XYZ& gp_Pnt::ChangeCoord ()
66{ return coord; }
67
68inline void gp_Pnt::BaryCenter(const Standard_Real A,
69 const gp_Pnt& P,
70 const Standard_Real B)
71{
72 coord.SetLinearForm(A,coord,B,P.coord);
73 coord.Divide(A + B);
74}
75
76inline Standard_Boolean gp_Pnt::IsEqual
77(const gp_Pnt& Other,
78 const Standard_Real LinearTolerance) const
79{ return Distance (Other) <= LinearTolerance; }
80
81inline Standard_Real gp_Pnt::Distance (const gp_Pnt& Other) const
82{
83 Standard_Real d=0,dd;
84 const gp_XYZ& XYZ = Other.coord;
85 dd = coord.X(); dd -= XYZ.X(); dd *= dd; d += dd;
86 dd = coord.Y(); dd -= XYZ.Y(); dd *= dd; d += dd;
87 dd = coord.Z(); dd -= XYZ.Z(); dd *= dd; d += dd;
88 return(sqrt(d));
89}
90
91inline Standard_Real gp_Pnt::SquareDistance (const gp_Pnt& Other) const
92{
93 Standard_Real d=0,dd;
94 const gp_XYZ& XYZ = Other.coord;
95 dd = coord.X(); dd -= XYZ.X(); dd *= dd; d += dd;
96 dd = coord.Y(); dd -= XYZ.Y(); dd *= dd; d += dd;
97 dd = coord.Z(); dd -= XYZ.Z(); dd *= dd; d += dd;
98 return(d);
99}
100
101inline void gp_Pnt::Rotate (const gp_Ax1& A1,
102 const Standard_Real Ang)
103{
104 gp_Trsf T;
105 T.SetRotation (A1, Ang);
106 T.Transforms (coord);
107}
108
109inline gp_Pnt gp_Pnt::Rotated (const gp_Ax1& A1,
110 const Standard_Real Ang) const
111{
112 gp_Pnt P = *this;
113 P.Rotate (A1, Ang);
114 return P;
115}
116
117inline void gp_Pnt::Scale (const gp_Pnt& P,
118 const Standard_Real S)
119{
120 gp_XYZ XYZ = P.coord;
121 XYZ.Multiply (1.0 - S);
122 coord.Multiply (S);
123 coord.Add (XYZ);
124}
125
126inline gp_Pnt gp_Pnt::Scaled (const gp_Pnt& P,
127 const Standard_Real S) const
128{
129 gp_Pnt Pres = *this;
130 Pres.Scale (P, S);
131 return Pres;
132}
133
134inline gp_Pnt gp_Pnt::Transformed (const gp_Trsf& T) const
135{
136 gp_Pnt P = *this;
137 P.Transform (T);
138 return P;
139}
140
141inline void gp_Pnt::Translate (const gp_Vec& V)
142{ coord.Add (V.XYZ()); }
143
144inline gp_Pnt gp_Pnt::Translated (const gp_Vec& V) const
145{
146 gp_Pnt P = *this;
147 P.coord.Add (V.XYZ());
148 return P;
149}
150
151inline void gp_Pnt::Translate (const gp_Pnt& P1,
152 const gp_Pnt& P2)
153{
154 coord.Add (P2.coord);
155 coord.Subtract (P1.coord);
156}
157
158inline gp_Pnt gp_Pnt::Translated (const gp_Pnt& P1,
159 const gp_Pnt& P2) const
160{
161 gp_Pnt P = *this;
162 P.Translate (P1 , P2);
163 return P;
164}
165