summaryrefslogtreecommitdiff
path: root/src/Geom2d/Geom2d_Parabola.cxx
blob: c1ff4d0f1ff14c25a2e4418a658eb42a178370a3 (plain)
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
// File:	Geom2d_Parabola.cxx
// Created:	Wed Mar 24 19:27:19 1993
// Author:	JCV
//		<fid@sdsun2>
// Copyright:	Matra Datavision 1993

//File Geom2d_Parabola.cxx, JCV 17/01/91

#include <Geom2d_Parabola.ixx>

#include <Precision.hxx>
#include <gp_XY.hxx>
#include <ElCLib.hxx>
#include <gp_Dir2d.hxx>
#include <Standard_ConstructionError.hxx>
#include <Standard_RangeError.hxx>

typedef Geom2d_Parabola         Parabola;
typedef Handle(Geom2d_Parabola) Handle(Parabola);
typedef gp_Ax2d   Ax2d;
typedef gp_Dir2d  Dir2d;
typedef gp_Pnt2d  Pnt2d;
typedef gp_Vec2d  Vec2d;
typedef gp_Trsf2d Trsf2d;
typedef gp_XY     XY;






//=======================================================================
//function : Copy
//purpose  : 
//=======================================================================

Handle(Geom2d_Geometry) Geom2d_Parabola::Copy() const 
{
  Handle(Parabola) Prb;
  Prb = new Parabola (pos, focalLength);
  return Prb;
}



//=======================================================================
//function : Geom2d_Parabola
//purpose  : 
//=======================================================================

Geom2d_Parabola::Geom2d_Parabola (const gp_Parab2d& Prb) 
{
  focalLength = Prb.Focal ();
  pos         = Prb.Axis();
}


//=======================================================================
//function : Geom2d_Parabola
//purpose  : 
//=======================================================================

Geom2d_Parabola::Geom2d_Parabola (const Ax2d& MirrorAxis, 
				  const Standard_Real Focal, 
				  const Standard_Boolean Sense) 
: focalLength (Focal) 
{
  if (Focal < 0.0) { Standard_ConstructionError::Raise(); }
  pos = gp_Ax22d(MirrorAxis, Sense);
}


//=======================================================================
//function : Geom2d_Parabola
//purpose  : 
//=======================================================================

Geom2d_Parabola::Geom2d_Parabola (const gp_Ax22d& Axis, const Standard_Real Focal)
: focalLength (Focal) 
{
  if (Focal < 0.0) { Standard_ConstructionError::Raise(); }
  pos  = Axis;
}


//=======================================================================
//function : Geom2d_Parabola
//purpose  : 
//=======================================================================

Geom2d_Parabola::Geom2d_Parabola (const Ax2d& D, const Pnt2d& F) {

  gp_Parab2d Prb (D, F);
  pos = Prb.Axis();
  focalLength = Prb.Focal();
}

//=======================================================================
//function : SetFocal
//purpose  : 
//=======================================================================

void Geom2d_Parabola::SetFocal (const Standard_Real Focal) 
{
  if (Focal < 0.0) Standard_ConstructionError::Raise();
  focalLength = Focal;
}


//=======================================================================
//function : SetParab2d
//purpose  : 
//=======================================================================

void Geom2d_Parabola::SetParab2d (const gp_Parab2d& Prb) 
{
  focalLength = Prb.Focal ();
  pos = Prb.Axis();
}

//=======================================================================
//function : Parab2d
//purpose  : 
//=======================================================================

gp_Parab2d Geom2d_Parabola::Parab2d () const 
{
  return gp_Parab2d (pos, focalLength);
}

//=======================================================================
//function : ReversedParameter
//purpose  : 
//=======================================================================

Standard_Real Geom2d_Parabola::ReversedParameter( const Standard_Real U) const
{
  return ( -U);
}

//=======================================================================
//function : FirstParameter
//purpose  : 
//=======================================================================

Standard_Real Geom2d_Parabola::FirstParameter () const   
{
  return -Precision::Infinite(); 
}

//=======================================================================
//function : LastParameter
//purpose  : 
//=======================================================================

Standard_Real Geom2d_Parabola::LastParameter () const    
{
  return Precision::Infinite(); 
}

//=======================================================================
//function : IsClosed
//purpose  : 
//=======================================================================

Standard_Boolean Geom2d_Parabola::IsClosed ()   const    
{
  return Standard_False; 
}

//=======================================================================
//function : IsPeriodic
//purpose  : 
//=======================================================================

Standard_Boolean Geom2d_Parabola::IsPeriodic () const    
{
  return Standard_False; 
}

//=======================================================================
//function : Directrix
//purpose  : 
//=======================================================================

Ax2d Geom2d_Parabola::Directrix () const 
{
  gp_Parab2d Prb (pos, focalLength);
  return Prb.Directrix();
}

//=======================================================================
//function : Eccentricity
//purpose  : 
//=======================================================================

Standard_Real Geom2d_Parabola::Eccentricity () const     
{
  return 1.0; 
}

//=======================================================================
//function : Focus
//purpose  : 
//=======================================================================

Pnt2d Geom2d_Parabola::Focus () const 
{
  XY Pxy = pos.XDirection().XY();
  Pxy.Multiply (focalLength);
  Pxy.Add (pos.Location().XY());
  return Pnt2d (Pxy);
}

//=======================================================================
//function : Focal
//purpose  : 
//=======================================================================

Standard_Real Geom2d_Parabola::Focal () const            
{
  return focalLength; 
}

//=======================================================================
//function : Parameter
//purpose  : 
//=======================================================================

Standard_Real Geom2d_Parabola::Parameter () const        
{
  return 2.0 * focalLength; 
}

//=======================================================================
//function : D0
//purpose  : 
//=======================================================================

void Geom2d_Parabola::D0 (const Standard_Real   U,
			        Pnt2d& P) const 
{
  P = ElCLib::ParabolaValue (U, pos, focalLength);
}

//=======================================================================
//function : D1
//purpose  : 
//=======================================================================

void Geom2d_Parabola::D1 (const Standard_Real U, Pnt2d& P, Vec2d& V1) const 
{
  ElCLib::ParabolaD1 (U, pos, focalLength, P, V1);
}

//=======================================================================
//function : D2
//purpose  : 
//=======================================================================

void Geom2d_Parabola::D2 (const Standard_Real U, 
			        Pnt2d& P, 
			        Vec2d& V1, Vec2d& V2) const 
{
  ElCLib::ParabolaD2 (U, pos, focalLength, P, V1, V2);
}

//=======================================================================
//function : D3
//purpose  : 
//=======================================================================

void Geom2d_Parabola::D3 (const Standard_Real U, 
			        Pnt2d& P, 
			        Vec2d& V1, Vec2d& V2, Vec2d& V3) const 
{
   ElCLib::ParabolaD2 (U, pos, focalLength, P, V1, V2);
   V3.SetCoord (0.0, 0.0);
}

//=======================================================================
//function : DN
//purpose  : 
//=======================================================================

Vec2d Geom2d_Parabola::DN (const Standard_Real U, const Standard_Integer N) const 
{
   Standard_RangeError_Raise_if (N < 1, " ");
   return ElCLib::ParabolaDN (U, pos, focalLength, N);
}


//=======================================================================
//function : Transform
//purpose  : 
//=======================================================================

void Geom2d_Parabola::Transform (const Trsf2d& T) 
{
  focalLength *= Abs(T.ScaleFactor());
   pos.Transform (T);
}

//=======================================================================
//function : TransformedParameter
//purpose  : 
//=======================================================================

Standard_Real Geom2d_Parabola::TransformedParameter(const Standard_Real U,
						    const gp_Trsf2d& T) const
{
  if (Precision::IsInfinite(U)) return U;
  return U * Abs(T.ScaleFactor());
}

//=======================================================================
//function : ParametricTransformation
//purpose  : 
//=======================================================================

Standard_Real Geom2d_Parabola::ParametricTransformation(const gp_Trsf2d& T) const
{
  return Abs(T.ScaleFactor());
}