0026377: Passing Handle objects as arguments to functions as non-const reference...
[occt.git] / src / gp / gp_Hypr2d.hxx
1 // Copyright (c) 1991-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
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.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 #ifndef _gp_Hypr2d_HeaderFile
16 #define _gp_Hypr2d_HeaderFile
17
18 #include <Standard.hxx>
19 #include <Standard_DefineAlloc.hxx>
20 #include <Standard_Handle.hxx>
21
22 #include <gp_Ax22d.hxx>
23 #include <Standard_Real.hxx>
24 #include <Standard_Boolean.hxx>
25 #include <gp_Ax2d.hxx>
26 #include <gp_Pnt2d.hxx>
27 class Standard_ConstructionError;
28 class Standard_DomainError;
29 class gp_Ax2d;
30 class gp_Ax22d;
31 class gp_Pnt2d;
32 class gp_Trsf2d;
33 class gp_Vec2d;
34
35
36
37 //! Describes a branch of a hyperbola in the plane (2D space).
38 //! A hyperbola is defined by its major and minor radii, and
39 //! positioned in the plane with a coordinate system (a
40 //! gp_Ax22d object) of which:
41 //! -   the origin is the center of the hyperbola,
42 //! -   the "X Direction" defines the major axis of the hyperbola, and
43 //! -   the "Y Direction" defines the minor axis of the hyperbola.
44 //! This coordinate system is the "local coordinate system"
45 //! of the hyperbola. The orientation of this coordinate
46 //! system (direct or indirect) gives an implicit orientation to
47 //! the hyperbola. In this coordinate system, the equation of
48 //! the hyperbola is:
49 //! X*X/(MajorRadius**2)-Y*Y/(MinorRadius**2) = 1.0
50 //! The branch of the hyperbola described is the one located
51 //! on the positive side of the major axis.
52 //! The following schema shows the plane of the hyperbola,
53 //! and in it, the respective positions of the three branches of
54 //! hyperbolas constructed with the functions OtherBranch,
55 //! ConjugateBranch1, and ConjugateBranch2:
56 //! ^YAxis
57 //! |
58 //! FirstConjugateBranch
59 //! |
60 //! Other            |                Main
61 //! --------------------- C ------------------------------>XAxis
62 //! Branch           |                Branch
63 //! |
64 //! |
65 //! SecondConjugateBranch
66 //! |
67 //!
68 //! Warning
69 //! The major radius can be less than the minor radius.
70 //! See Also
71 //! gce_MakeHypr2d which provides functions for more
72 //! complex hyperbola constructions
73 //! Geom2d_Hyperbola which provides additional functions
74 //! for constructing hyperbolas and works, in particular, with
75 //! the parametric equations of hyperbolas
76 class gp_Hypr2d 
77 {
78 public:
79
80   DEFINE_STANDARD_ALLOC
81
82   
83   //! Creates of an indefinite hyperbola.
84     gp_Hypr2d();
85   
86
87   //! Creates a hyperbola with radii MajorRadius and
88   //! MinorRadius, centered on the origin of MajorAxis
89   //! and where the unit vector of MajorAxis is the "X
90   //! Direction" of the local coordinate system of the
91   //! hyperbola. This coordinate system is direct if Sense
92   //! is true (the default value), and indirect if Sense is false.
93   //! Warnings :
94   //! It is yet  possible to create an Hyperbola with
95   //! MajorRadius <= MinorRadius.
96   //! Raises ConstructionError if MajorRadius < 0.0 or MinorRadius < 0.0
97   Standard_EXPORT gp_Hypr2d(const gp_Ax2d& MajorAxis, const Standard_Real MajorRadius, const Standard_Real MinorRadius, const Standard_Boolean Sense = Standard_True);
98   
99
100   //! a hyperbola with radii MajorRadius and
101   //! MinorRadius, positioned in the plane by coordinate system A where:
102   //! -   the origin of A is the center of the hyperbola,
103   //! -   the "X Direction" of A defines the major axis of
104   //! the hyperbola, that is, the major radius
105   //! MajorRadius is measured along this axis, and
106   //! -   the "Y Direction" of A defines the minor axis of
107   //! the hyperbola, that is, the minor radius
108   //! MinorRadius is measured along this axis, and
109   //! -   the orientation (direct or indirect sense) of A
110   //! gives the implicit orientation of the hyperbola.
111   //! Warnings :
112   //! It is yet  possible to create an Hyperbola with
113   //! MajorRadius <= MinorRadius.
114   //! Raises ConstructionError if MajorRadius < 0.0 or MinorRadius < 0.0
115     gp_Hypr2d(const gp_Ax22d& A, const Standard_Real MajorRadius, const Standard_Real MinorRadius);
116   
117   //! Modifies this hyperbola, by redefining its local
118   //! coordinate system so that its origin becomes P.
119     void SetLocation (const gp_Pnt2d& P);
120   
121   //! Modifies the major or minor radius of this hyperbola.
122   //! Exceptions
123   //! Standard_ConstructionError if MajorRadius or
124   //! MinorRadius is negative.
125     void SetMajorRadius (const Standard_Real MajorRadius);
126   
127   //! Modifies the major or minor radius of this hyperbola.
128   //! Exceptions
129   //! Standard_ConstructionError if MajorRadius or
130   //! MinorRadius is negative.
131     void SetMinorRadius (const Standard_Real MinorRadius);
132   
133   //! Modifies this hyperbola, by redefining its local
134   //! coordinate system so that it becomes A.
135     void SetAxis (const gp_Ax22d& A);
136   
137
138   //! Changes the major axis of the hyperbola. The minor axis is
139   //! recomputed and the location of the hyperbola too.
140     void SetXAxis (const gp_Ax2d& A);
141   
142
143   //! Changes the minor axis of the hyperbola.The minor axis is
144   //! recomputed and the location of the hyperbola too.
145     void SetYAxis (const gp_Ax2d& A);
146   
147
148   //! In the local coordinate system of the hyperbola the equation of
149   //! the hyperbola is (X*X)/(A*A) - (Y*Y)/(B*B) = 1.0 and the
150   //! equation of the first asymptote is Y = (B/A)*X
151   //! where A is the major radius of the hyperbola and B the minor
152   //! radius of the hyperbola.
153   //! Raises ConstructionError if MajorRadius = 0.0
154     gp_Ax2d Asymptote1() const;
155   
156
157   //! In the local coordinate system of the hyperbola the equation of
158   //! the hyperbola is (X*X)/(A*A) - (Y*Y)/(B*B) = 1.0 and the
159   //! equation of the first asymptote is Y = -(B/A)*X
160   //! where A is the major radius of the hyperbola and B the minor
161   //! radius of the hyperbola.
162   //! Raises ConstructionError if MajorRadius = 0.0
163     gp_Ax2d Asymptote2() const;
164   
165
166   //! Computes the coefficients of the implicit equation of
167   //! the hyperbola :
168   //! A * (X**2) + B * (Y**2) + 2*C*(X*Y) + 2*D*X + 2*E*Y + F = 0.
169   Standard_EXPORT void Coefficients (Standard_Real& A, Standard_Real& B, Standard_Real& C, Standard_Real& D, Standard_Real& E, Standard_Real& F) const;
170   
171
172   //! Computes the branch of hyperbola which is on the positive side of the
173   //! "YAxis" of <me>.
174     gp_Hypr2d ConjugateBranch1() const;
175   
176
177   //! Computes the branch of hyperbola which is on the negative side of the
178   //! "YAxis" of <me>.
179     gp_Hypr2d ConjugateBranch2() const;
180   
181
182   //! Computes the directrix which is the line normal to the XAxis of the hyperbola
183   //! in the local plane (Z = 0) at a distance d = MajorRadius / e
184   //! from the center of the hyperbola, where e is the eccentricity of
185   //! the hyperbola.
186   //! This line is parallel to the "YAxis". The intersection point
187   //! between the "Directrix1" and the "XAxis" is the "Location" point
188   //! of the "Directrix1".
189   //! This point is on the positive side of the "XAxis".
190     gp_Ax2d Directrix1() const;
191   
192
193   //! This line is obtained by the symmetrical transformation
194   //! of "Directrix1" with respect to the "YAxis" of the hyperbola.
195     gp_Ax2d Directrix2() const;
196   
197
198   //! Returns the excentricity of the hyperbola (e > 1).
199   //! If f is the distance between the location of the hyperbola
200   //! and the Focus1 then the eccentricity e = f / MajorRadius. Raises DomainError if MajorRadius = 0.0.
201     Standard_Real Eccentricity() const;
202   
203
204   //! Computes the focal distance. It is the distance between the
205   //! "Location" of the hyperbola and "Focus1" or "Focus2".
206     Standard_Real Focal() const;
207   
208
209   //! Returns the first focus of the hyperbola. This focus is on the
210   //! positive side of the "XAxis" of the hyperbola.
211     gp_Pnt2d Focus1() const;
212   
213
214   //! Returns the second focus of the hyperbola. This focus is on the
215   //! negative side of the "XAxis" of the hyperbola.
216     gp_Pnt2d Focus2() const;
217   
218
219   //! Returns  the location point of the hyperbola.
220   //! It is the intersection point between the "XAxis" and
221   //! the "YAxis".
222     const gp_Pnt2d& Location() const;
223   
224
225   //! Returns the major radius of the hyperbola (it is the radius
226   //! corresponding to the "XAxis" of the hyperbola).
227     Standard_Real MajorRadius() const;
228   
229
230   //! Returns the minor radius of the hyperbola (it is the radius
231   //! corresponding to the "YAxis" of the hyperbola).
232     Standard_Real MinorRadius() const;
233   
234
235   //! Returns the branch of hyperbola obtained by doing the
236   //! symmetrical transformation of <me> with respect to the
237   //! "YAxis" of <me>.
238     gp_Hypr2d OtherBranch() const;
239   
240
241   //! Returns p = (e * e - 1) * MajorRadius where e is the
242   //! eccentricity of the hyperbola.
243   //! Raises DomainError if MajorRadius = 0.0
244     Standard_Real Parameter() const;
245   
246   //! Returns the axisplacement of the hyperbola.
247     const gp_Ax22d& Axis() const;
248   
249   //! Computes an axis whose
250   //! -   the origin is the center of this hyperbola, and
251   //! -   the unit vector is the "X Direction" or "Y Direction"
252   //! respectively of the local coordinate system of this hyperbola
253   //! Returns the major axis of the hyperbola.
254   Standard_EXPORT gp_Ax2d XAxis() const;
255   
256   //! Computes an axis whose
257   //! -   the origin is the center of this hyperbola, and
258   //! -   the unit vector is the "X Direction" or "Y Direction"
259   //! respectively of the local coordinate system of this hyperbola
260   //! Returns the minor axis of the hyperbola.
261     gp_Ax2d YAxis() const;
262   
263     void Reverse();
264   
265   //! Reverses the orientation of the local coordinate system
266   //! of this hyperbola (the "Y Axis" is reversed). Therefore,
267   //! the implicit orientation of this hyperbola is reversed.
268   //! Note:
269   //! -   Reverse assigns the result to this hyperbola, while
270   //! -   Reversed creates a new one.
271     gp_Hypr2d Reversed() const;
272   
273   //! Returns true if the local coordinate system is direct
274   //! and false in the other case.
275     Standard_Boolean IsDirect() const;
276   
277   Standard_EXPORT void Mirror (const gp_Pnt2d& P);
278   
279
280   //! Performs the symmetrical transformation of an hyperbola with
281   //! respect  to the point P which is the center of the symmetry.
282   Standard_EXPORT gp_Hypr2d Mirrored (const gp_Pnt2d& P) const;
283   
284   Standard_EXPORT void Mirror (const gp_Ax2d& A);
285   
286
287   //! Performs the symmetrical transformation of an hyperbola with
288   //! respect to an axis placement which is the axis of the symmetry.
289   Standard_EXPORT gp_Hypr2d Mirrored (const gp_Ax2d& A) const;
290   
291     void Rotate (const gp_Pnt2d& P, const Standard_Real Ang);
292   
293
294   //! Rotates an hyperbola. P is the center of the rotation.
295   //! Ang is the angular value of the rotation in radians.
296     gp_Hypr2d Rotated (const gp_Pnt2d& P, const Standard_Real Ang) const;
297   
298     void Scale (const gp_Pnt2d& P, const Standard_Real S);
299   
300
301   //! Scales an hyperbola. <S> is the scaling value.
302   //! If <S> is positive only the location point is
303   //! modified. But if <S> is negative the "XAxis" is
304   //! reversed and the "YAxis" too.
305     gp_Hypr2d Scaled (const gp_Pnt2d& P, const Standard_Real S) const;
306   
307     void Transform (const gp_Trsf2d& T);
308   
309
310   //! Transforms an hyperbola with the transformation T from
311   //! class Trsf2d.
312     gp_Hypr2d Transformed (const gp_Trsf2d& T) const;
313   
314     void Translate (const gp_Vec2d& V);
315   
316
317   //! Translates an hyperbola in the direction of the vector V.
318   //! The magnitude of the translation is the vector's magnitude.
319     gp_Hypr2d Translated (const gp_Vec2d& V) const;
320   
321     void Translate (const gp_Pnt2d& P1, const gp_Pnt2d& P2);
322   
323
324   //! Translates an hyperbola from the point P1 to the point P2.
325     gp_Hypr2d Translated (const gp_Pnt2d& P1, const gp_Pnt2d& P2) const;
326
327
328
329
330 protected:
331
332
333
334
335
336 private:
337
338
339
340   gp_Ax22d pos;
341   Standard_Real majorRadius;
342   Standard_Real minorRadius;
343
344
345 };
346
347
348 #include <gp_Hypr2d.lxx>
349
350
351
352
353
354 #endif // _gp_Hypr2d_HeaderFile