1 // Copyright (c) 1991-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #ifndef _gp_Hypr2d_HeaderFile
16 #define _gp_Hypr2d_HeaderFile
18 #include <Standard.hxx>
19 #include <Standard_DefineAlloc.hxx>
20 #include <Standard_Handle.hxx>
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;
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
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:
58 //! FirstConjugateBranch
61 //! --------------------- C ------------------------------>XAxis
65 //! SecondConjugateBranch
69 //! The major radius can be less than the minor radius.
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
83 //! Creates of an indefinite hyperbola.
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.
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);
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.
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);
117 //! Modifies this hyperbola, by redefining its local
118 //! coordinate system so that its origin becomes P.
119 void SetLocation (const gp_Pnt2d& P);
121 //! Modifies the major or minor radius of this hyperbola.
123 //! Standard_ConstructionError if MajorRadius or
124 //! MinorRadius is negative.
125 void SetMajorRadius (const Standard_Real MajorRadius);
127 //! Modifies the major or minor radius of this hyperbola.
129 //! Standard_ConstructionError if MajorRadius or
130 //! MinorRadius is negative.
131 void SetMinorRadius (const Standard_Real MinorRadius);
133 //! Modifies this hyperbola, by redefining its local
134 //! coordinate system so that it becomes A.
135 void SetAxis (const gp_Ax22d& A);
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);
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);
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;
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;
166 //! Computes the coefficients of the implicit equation of
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;
172 //! Computes the branch of hyperbola which is on the positive side of the
174 gp_Hypr2d ConjugateBranch1() const;
177 //! Computes the branch of hyperbola which is on the negative side of the
179 gp_Hypr2d ConjugateBranch2() const;
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
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;
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;
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;
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;
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;
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;
219 //! Returns the location point of the hyperbola.
220 //! It is the intersection point between the "XAxis" and
222 const gp_Pnt2d& Location() const;
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;
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;
235 //! Returns the branch of hyperbola obtained by doing the
236 //! symmetrical transformation of <me> with respect to the
238 gp_Hypr2d OtherBranch() const;
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;
246 //! Returns the axisplacement of the hyperbola.
247 const gp_Ax22d& Axis() const;
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;
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;
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.
269 //! - Reverse assigns the result to this hyperbola, while
270 //! - Reversed creates a new one.
271 gp_Hypr2d Reversed() const;
273 //! Returns true if the local coordinate system is direct
274 //! and false in the other case.
275 Standard_Boolean IsDirect() const;
277 Standard_EXPORT void Mirror (const gp_Pnt2d& P);
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;
284 Standard_EXPORT void Mirror (const gp_Ax2d& A);
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;
291 void Rotate (const gp_Pnt2d& P, const Standard_Real Ang);
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;
298 void Scale (const gp_Pnt2d& P, const Standard_Real S);
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;
307 void Transform (const gp_Trsf2d& T);
310 //! Transforms an hyperbola with the transformation T from
312 gp_Hypr2d Transformed (const gp_Trsf2d& T) const;
314 void Translate (const gp_Vec2d& V);
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;
321 void Translate (const gp_Pnt2d& P1, const gp_Pnt2d& P2);
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;
341 Standard_Real majorRadius;
342 Standard_Real minorRadius;
348 #include <gp_Hypr2d.lxx>
354 #endif // _gp_Hypr2d_HeaderFile