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_Elips2d_HeaderFile
16 #define _gp_Elips2d_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;
36 //! Describes an ellipse in the plane (2D space).
37 //! An ellipse is defined by its major and minor radii and
38 //! positioned in the plane with a coordinate system (a
39 //! gp_Ax22d object) as follows:
40 //! - the origin of the coordinate system is the center of the ellipse,
41 //! - its "X Direction" defines the major axis of the ellipse, and
42 //! - its "Y Direction" defines the minor axis of the ellipse.
43 //! This coordinate system is the "local coordinate system"
44 //! of the ellipse. Its orientation (direct or indirect) gives an
45 //! implicit orientation to the ellipse. In this coordinate
46 //! system, the equation of the ellipse is:
47 //! X*X / (MajorRadius**2) + Y*Y / (MinorRadius**2) = 1.0
49 //! gce_MakeElips2d which provides functions for more
50 //! complex ellipse constructions
51 //! Geom2d_Ellipse which provides additional functions for
52 //! constructing ellipses and works, in particular, with the
53 //! parametric equations of ellipses
61 //! Creates an indefinite ellipse.
65 //! Creates an ellipse with the major axis, the major and the
66 //! minor radius. The location of the MajorAxis is the center
68 //! The sense of parametrization is given by Sense.
70 //! It is possible to create an ellipse with
71 //! MajorRadius = MinorRadius.
72 //! Raises ConstructionError if MajorRadius < MinorRadius or MinorRadius < 0.0
73 gp_Elips2d(const gp_Ax2d& MajorAxis, const Standard_Real MajorRadius, const Standard_Real MinorRadius, const Standard_Boolean Sense = Standard_True);
75 //! Creates an ellipse with radii MajorRadius and
76 //! MinorRadius, positioned in the plane by coordinate system A where:
77 //! - the origin of A is the center of the ellipse,
78 //! - the "X Direction" of A defines the major axis of
79 //! the ellipse, that is, the major radius MajorRadius
80 //! is measured along this axis, and
81 //! - the "Y Direction" of A defines the minor axis of
82 //! the ellipse, that is, the minor radius MinorRadius
83 //! is measured along this axis, and
84 //! - the orientation (direct or indirect sense) of A
85 //! gives the orientation of the ellipse.
87 //! It is possible to create an ellipse with
88 //! MajorRadius = MinorRadius.
89 //! Raises ConstructionError if MajorRadius < MinorRadius or MinorRadius < 0.0
90 gp_Elips2d(const gp_Ax22d& A, const Standard_Real MajorRadius, const Standard_Real MinorRadius);
92 //! Modifies this ellipse, by redefining its local coordinate system so that
93 //! - its origin becomes P.
94 void SetLocation (const gp_Pnt2d& P);
96 //! Changes the value of the major radius.
97 //! Raises ConstructionError if MajorRadius < MinorRadius.
98 void SetMajorRadius (const Standard_Real MajorRadius);
100 //! Changes the value of the minor radius.
101 //! Raises ConstructionError if MajorRadius < MinorRadius or MinorRadius < 0.0
102 void SetMinorRadius (const Standard_Real MinorRadius);
104 //! Modifies this ellipse, by redefining its local coordinate system so that
106 void SetAxis (const gp_Ax22d& A);
108 //! Modifies this ellipse, by redefining its local coordinate system so that
109 //! its origin and its "X Direction" become those
110 //! of the axis A. The "Y Direction" is then
111 //! recomputed. The orientation of the local coordinate
112 //! system is not modified.
113 void SetXAxis (const gp_Ax2d& A);
115 //! Modifies this ellipse, by redefining its local coordinate system so that
116 //! its origin and its "Y Direction" become those
117 //! of the axis A. The "X Direction" is then
118 //! recomputed. The orientation of the local coordinate
119 //! system is not modified.
120 void SetYAxis (const gp_Ax2d& A);
122 //! Computes the area of the ellipse.
123 Standard_Real Area() const;
126 //! Returns the coefficients of the implicit equation of the ellipse.
127 //! A * (X**2) + B * (Y**2) + 2*C*(X*Y) + 2*D*X + 2*E*Y + F = 0.
128 Standard_EXPORT void Coefficients (Standard_Real& A, Standard_Real& B, Standard_Real& C, Standard_Real& D, Standard_Real& E, Standard_Real& F) const;
131 //! This directrix is the line normal to the XAxis of the ellipse
132 //! in the local plane (Z = 0) at a distance d = MajorRadius / e
133 //! from the center of the ellipse, where e is the eccentricity of
135 //! This line is parallel to the "YAxis". The intersection point
136 //! between directrix1 and the "XAxis" is the location point of the
137 //! directrix1. This point is on the positive side of the "XAxis".
139 //! Raised if Eccentricity = 0.0. (The ellipse degenerates into a
141 gp_Ax2d Directrix1() const;
144 //! This line is obtained by the symmetrical transformation
145 //! of "Directrix1" with respect to the minor axis of the ellipse.
147 //! Raised if Eccentricity = 0.0. (The ellipse degenerates into a
149 gp_Ax2d Directrix2() const;
152 //! Returns the eccentricity of the ellipse between 0.0 and 1.0
153 //! If f is the distance between the center of the ellipse and
154 //! the Focus1 then the eccentricity e = f / MajorRadius.
155 //! Returns 0 if MajorRadius = 0.
156 Standard_Real Eccentricity() const;
159 //! Returns the distance between the center of the ellipse
160 //! and focus1 or focus2.
161 Standard_Real Focal() const;
164 //! Returns the first focus of the ellipse. This focus is on the
165 //! positive side of the major axis of the ellipse.
166 gp_Pnt2d Focus1() const;
169 //! Returns the second focus of the ellipse. This focus is on the
170 //! negative side of the major axis of the ellipse.
171 gp_Pnt2d Focus2() const;
173 //! Returns the center of the ellipse.
174 const gp_Pnt2d& Location() const;
176 //! Returns the major radius of the Ellipse.
177 Standard_Real MajorRadius() const;
179 //! Returns the minor radius of the Ellipse.
180 Standard_Real MinorRadius() const;
183 //! Returns p = (1 - e * e) * MajorRadius where e is the eccentricity
185 //! Returns 0 if MajorRadius = 0
186 Standard_Real Parameter() const;
188 //! Returns the major axis of the ellipse.
189 const gp_Ax22d& Axis() const;
191 //! Returns the major axis of the ellipse.
192 gp_Ax2d XAxis() const;
194 //! Returns the minor axis of the ellipse.
195 //! Reverses the direction of the circle.
196 gp_Ax2d YAxis() const;
200 gp_Elips2d Reversed() const;
202 //! Returns true if the local coordinate system is direct
203 //! and false in the other case.
204 Standard_Boolean IsDirect() const;
206 Standard_EXPORT void Mirror (const gp_Pnt2d& P);
209 //! Performs the symmetrical transformation of a ellipse with respect
210 //! to the point P which is the center of the symmetry
211 Standard_EXPORT gp_Elips2d Mirrored (const gp_Pnt2d& P) const;
213 Standard_EXPORT void Mirror (const gp_Ax2d& A);
216 //! Performs the symmetrical transformation of a ellipse with respect
217 //! to an axis placement which is the axis of the symmetry.
218 Standard_EXPORT gp_Elips2d Mirrored (const gp_Ax2d& A) const;
220 void Rotate (const gp_Pnt2d& P, const Standard_Real Ang);
222 gp_Elips2d Rotated (const gp_Pnt2d& P, const Standard_Real Ang) const;
224 void Scale (const gp_Pnt2d& P, const Standard_Real S);
227 //! Scales a ellipse. S is the scaling value.
228 gp_Elips2d Scaled (const gp_Pnt2d& P, const Standard_Real S) const;
230 void Transform (const gp_Trsf2d& T);
233 //! Transforms an ellipse with the transformation T from class Trsf2d.
234 gp_Elips2d Transformed (const gp_Trsf2d& T) const;
236 void Translate (const gp_Vec2d& V);
239 //! Translates a ellipse in the direction of the vector V.
240 //! The magnitude of the translation is the vector's magnitude.
241 gp_Elips2d Translated (const gp_Vec2d& V) const;
243 void Translate (const gp_Pnt2d& P1, const gp_Pnt2d& P2);
246 //! Translates a ellipse from the point P1 to the point P2.
247 gp_Elips2d Translated (const gp_Pnt2d& P1, const gp_Pnt2d& P2) const;
263 Standard_Real majorRadius;
264 Standard_Real minorRadius;
270 #include <gp_Elips2d.lxx>
276 #endif // _gp_Elips2d_HeaderFile