1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
// File gp_Dir.lxx , JCV 01/10/90
#include <gp_Vec.hxx>
#include <gp_Trsf.hxx>
#include <Standard_ConstructionError.hxx>
#include <Standard_OutOfRange.hxx>
inline gp_Dir::gp_Dir () : coord(1.,0.,0.)
{
}
inline gp_Dir::gp_Dir (const gp_Vec& V)
{
const gp_XYZ& XYZ = V.XYZ();
Standard_Real X = XYZ.X();
Standard_Real Y = XYZ.Y();
Standard_Real Z = XYZ.Z();
Standard_Real D = sqrt(X * X + Y * Y + Z * Z);
Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
coord.SetX(X / D);
coord.SetY(Y / D);
coord.SetZ(Z / D);
}
inline gp_Dir::gp_Dir (const gp_XYZ& XYZ)
{
Standard_Real X = XYZ.X();
Standard_Real Y = XYZ.Y();
Standard_Real Z = XYZ.Z();
Standard_Real D = sqrt(X * X + Y * Y + Z * Z);
Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
coord.SetX(X / D);
coord.SetY(Y / D);
coord.SetZ(Z / D);
}
inline gp_Dir::gp_Dir (const Standard_Real Xv,
const Standard_Real Yv,
const Standard_Real Zv)
{
Standard_Real D = sqrt (Xv * Xv + Yv * Yv + Zv * Zv);
Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
coord.SetX(Xv / D);
coord.SetY(Yv / D);
coord.SetZ(Zv / D);
}
inline void gp_Dir::SetCoord (const Standard_Integer Index,
const Standard_Real Xi)
{
Standard_Real X = coord.X();
Standard_Real Y = coord.Y();
Standard_Real Z = coord.Z();
Standard_OutOfRange_Raise_if (Index < 1 || Index > 3, " ");
if (Index == 1) X = Xi;
else if (Index == 2) Y = Xi;
else Z = Xi;
Standard_Real D = sqrt (X * X + Y * Y + Z * Z);
Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
coord.SetX(X / D);
coord.SetY(Y / D);
coord.SetZ(Z / D);
}
inline void gp_Dir::SetCoord (const Standard_Real Xv,
const Standard_Real Yv,
const Standard_Real Zv) {
Standard_Real D = sqrt(Xv * Xv + Yv * Yv + Zv * Zv);
Standard_ConstructionError_Raise_if(D <= gp::Resolution(), "");
coord.SetX(Xv / D);
coord.SetY(Yv / D);
coord.SetZ(Zv / D);
}
inline void gp_Dir::SetX (const Standard_Real X)
{
Standard_Real Y = coord.Y();
Standard_Real Z = coord.Z();
Standard_Real D = sqrt (X * X + Y * Y + Z * Z);
Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
coord.SetX(X / D);
coord.SetY(Y / D);
coord.SetZ(Z / D);
}
inline void gp_Dir::SetY (const Standard_Real Y)
{
Standard_Real Z = coord.Z();
Standard_Real X = coord.X();
Standard_Real D = sqrt (X * X + Y * Y + Z * Z);
Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
coord.SetX(X / D);
coord.SetY(Y / D);
coord.SetZ(Z / D);
}
inline void gp_Dir::SetZ (const Standard_Real Z)
{
Standard_Real X = coord.X();
Standard_Real Y = coord.Y();
Standard_Real D = sqrt (X * X + Y * Y + Z * Z);
Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
coord.SetX(X / D);
coord.SetY(Y / D);
coord.SetZ(Z / D);
}
inline void gp_Dir::SetXYZ (const gp_XYZ& XYZ)
{
Standard_Real X = XYZ.X();
Standard_Real Y = XYZ.Y();
Standard_Real Z = XYZ.Z();
Standard_Real D = sqrt(X * X + Y * Y + Z * Z);
Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
coord.SetX(X / D);
coord.SetY(Y / D);
coord.SetZ(Z / D);
}
inline Standard_Real gp_Dir::Coord (const Standard_Integer Index) const
{ return coord.Coord (Index);}
inline void gp_Dir::Coord (Standard_Real& Xv,
Standard_Real& Yv,
Standard_Real& Zv) const
{ coord.Coord (Xv, Yv, Zv); }
inline Standard_Real gp_Dir::X() const
{ return coord.X() ; }
inline Standard_Real gp_Dir::Y() const
{ return coord.Y() ; }
inline Standard_Real gp_Dir::Z() const
{ return coord.Z() ; }
inline const gp_XYZ& gp_Dir::XYZ () const
{ return coord; }
inline Standard_Boolean gp_Dir::IsEqual
(const gp_Dir& Other,
const Standard_Real AngularTolerance) const
{ return Angle (Other) <= AngularTolerance; }
inline Standard_Boolean gp_Dir::IsNormal
(const gp_Dir& Other,
const Standard_Real AngularTolerance) const
{
Standard_Real Ang = Standard_PI / 2.0 - Angle (Other);
if (Ang < 0) Ang = - Ang;
return Ang <= AngularTolerance;
}
inline Standard_Boolean gp_Dir::IsOpposite
(const gp_Dir& Other,
const Standard_Real AngularTolerance) const
{ return Standard_PI - Angle (Other) <= AngularTolerance; }
inline Standard_Boolean gp_Dir::IsParallel
(const gp_Dir& Other,
const Standard_Real AngularTolerance) const
{
Standard_Real Ang = Angle (Other);
return Ang <= AngularTolerance || Standard_PI - Ang <= AngularTolerance;
}
inline void gp_Dir::Cross (const gp_Dir& Right)
{
coord.Cross (Right.coord);
Standard_Real D = coord.Modulus ();
Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
coord.Divide (D);
}
inline gp_Dir gp_Dir::Crossed (const gp_Dir& Right) const
{
gp_Dir V = *this;
V.coord.Cross (Right.coord);
Standard_Real D = V.coord.Modulus();
Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
V.coord.Divide (D);
return V;
}
inline void gp_Dir::CrossCross (const gp_Dir& V1,
const gp_Dir& V2)
{
coord.CrossCross (V1.coord, V2.coord);
Standard_Real D = coord.Modulus();
Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
coord.Divide(D);
}
inline gp_Dir gp_Dir::CrossCrossed (const gp_Dir& V1,
const gp_Dir& V2) const
{
gp_Dir V = *this;
(V.coord).CrossCross (V1.coord, V2.coord);
Standard_Real D = V.coord.Modulus();
Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
V.coord.Divide(D);
return V;
}
inline Standard_Real gp_Dir::Dot (const gp_Dir& Other) const
{ return coord.Dot (Other.coord); }
inline Standard_Real gp_Dir::DotCross (const gp_Dir& V1,
const gp_Dir& V2) const
{ return coord.Dot (V1.coord.Crossed (V2.coord)); }
inline void gp_Dir::Reverse ()
{ coord.Reverse(); }
inline gp_Dir gp_Dir::Reversed () const {
gp_Dir V = *this;
V.coord.Reverse ();
return V;
}
inline void gp_Dir::Rotate (const gp_Ax1& A1, const Standard_Real Ang)
{
gp_Trsf T;
T.SetRotation (A1, Ang);
coord.Multiply (T.HVectorialPart ());
}
inline gp_Dir gp_Dir::Rotated (const gp_Ax1& A1,
const Standard_Real Ang) const
{
gp_Dir V = *this;
V.Rotate (A1, Ang);
return V;
}
inline gp_Dir gp_Dir::Transformed (const gp_Trsf& T) const
{
gp_Dir V = *this;
V.Transform (T);
return V;
}
|