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:
48 //! X*X / (MajorRadius**2) + Y*Y / (MinorRadius**2) = 1.0
51 //! gce_MakeElips2d which provides functions for more
52 //! complex ellipse constructions
53 //! Geom2d_Ellipse which provides additional functions for
54 //! constructing ellipses and works, in particular, with the
55 //! parametric equations of ellipses
63 //! Creates an indefinite ellipse.
67 //! Creates an ellipse with the major axis, the major and the
68 //! minor radius. The location of the MajorAxis is the center
70 //! The sense of parametrization is given by Sense.
72 //! It is possible to create an ellipse with
73 //! MajorRadius = MinorRadius.
74 //! Raises ConstructionError if MajorRadius < MinorRadius or MinorRadius < 0.0
75 gp_Elips2d(const gp_Ax2d& MajorAxis, const Standard_Real MajorRadius, const Standard_Real MinorRadius, const Standard_Boolean Sense = Standard_True);
77 //! Creates an ellipse with radii MajorRadius and
78 //! MinorRadius, positioned in the plane by coordinate system A where:
79 //! - the origin of A is the center of the ellipse,
80 //! - the "X Direction" of A defines the major axis of
81 //! the ellipse, that is, the major radius MajorRadius
82 //! is measured along this axis, and
83 //! - the "Y Direction" of A defines the minor axis of
84 //! the ellipse, that is, the minor radius MinorRadius
85 //! is measured along this axis, and
86 //! - the orientation (direct or indirect sense) of A
87 //! gives the orientation of the ellipse.
89 //! It is possible to create an ellipse with
90 //! MajorRadius = MinorRadius.
91 //! Raises ConstructionError if MajorRadius < MinorRadius or MinorRadius < 0.0
92 gp_Elips2d(const gp_Ax22d& A, const Standard_Real MajorRadius, const Standard_Real MinorRadius);
94 //! Modifies this ellipse, by redefining its local coordinate system so that
95 //! - its origin becomes P.
96 void SetLocation (const gp_Pnt2d& P);
98 //! Changes the value of the major radius.
99 //! Raises ConstructionError if MajorRadius < MinorRadius.
100 void SetMajorRadius (const Standard_Real MajorRadius);
102 //! Changes the value of the minor radius.
103 //! Raises ConstructionError if MajorRadius < MinorRadius or MinorRadius < 0.0
104 void SetMinorRadius (const Standard_Real MinorRadius);
106 //! Modifies this ellipse, by redefining its local coordinate system so that
108 void SetAxis (const gp_Ax22d& A);
110 //! Modifies this ellipse, by redefining its local coordinate system so that
111 //! its origin and its "X Direction" become those
112 //! of the axis A. The "Y Direction" is then
113 //! recomputed. The orientation of the local coordinate
114 //! system is not modified.
115 void SetXAxis (const gp_Ax2d& A);
117 //! Modifies this ellipse, by redefining its local coordinate system so that
118 //! its origin and its "Y Direction" become those
119 //! of the axis A. The "X Direction" is then
120 //! recomputed. The orientation of the local coordinate
121 //! system is not modified.
122 void SetYAxis (const gp_Ax2d& A);
124 //! Computes the area of the ellipse.
125 Standard_Real Area() const;
128 //! Returns the coefficients of the implicit equation of the ellipse.
129 //! A * (X**2) + B * (Y**2) + 2*C*(X*Y) + 2*D*X + 2*E*Y + F = 0.
130 Standard_EXPORT void Coefficients (Standard_Real& A, Standard_Real& B, Standard_Real& C, Standard_Real& D, Standard_Real& E, Standard_Real& F) const;
133 //! This directrix is the line normal to the XAxis of the ellipse
134 //! in the local plane (Z = 0) at a distance d = MajorRadius / e
135 //! from the center of the ellipse, where e is the eccentricity of
137 //! This line is parallel to the "YAxis". The intersection point
138 //! between directrix1 and the "XAxis" is the location point of the
139 //! directrix1. This point is on the positive side of the "XAxis".
141 //! Raised if Eccentricity = 0.0. (The ellipse degenerates into a
143 gp_Ax2d Directrix1() const;
146 //! This line is obtained by the symmetrical transformation
147 //! of "Directrix1" with respect to the minor axis of the ellipse.
149 //! Raised if Eccentricity = 0.0. (The ellipse degenerates into a
151 gp_Ax2d Directrix2() const;
154 //! Returns the eccentricity of the ellipse between 0.0 and 1.0
155 //! If f is the distance between the center of the ellipse and
156 //! the Focus1 then the eccentricity e = f / MajorRadius.
157 //! Returns 0 if MajorRadius = 0.
158 Standard_Real Eccentricity() const;
161 //! Returns the distance between the center of the ellipse
162 //! and focus1 or focus2.
163 Standard_Real Focal() const;
166 //! Returns the first focus of the ellipse. This focus is on the
167 //! positive side of the major axis of the ellipse.
168 gp_Pnt2d Focus1() const;
171 //! Returns the second focus of the ellipse. This focus is on the
172 //! negative side of the major axis of the ellipse.
173 gp_Pnt2d Focus2() const;
175 //! Returns the center of the ellipse.
176 const gp_Pnt2d& Location() const;
178 //! Returns the major radius of the Ellipse.
179 Standard_Real MajorRadius() const;
181 //! Returns the minor radius of the Ellipse.
182 Standard_Real MinorRadius() const;
185 //! Returns p = (1 - e * e) * MajorRadius where e is the eccentricity
187 //! Returns 0 if MajorRadius = 0
188 Standard_Real Parameter() const;
190 //! Returns the major axis of the ellipse.
191 const gp_Ax22d& Axis() const;
193 //! Returns the major axis of the ellipse.
194 gp_Ax2d XAxis() const;
196 //! Returns the minor axis of the ellipse.
197 //! Reverses the direction of the circle.
198 gp_Ax2d YAxis() const;
202 Standard_NODISCARD gp_Elips2d Reversed() const;
204 //! Returns true if the local coordinate system is direct
205 //! and false in the other case.
206 Standard_Boolean IsDirect() const;
208 Standard_EXPORT void Mirror (const gp_Pnt2d& P);
211 //! Performs the symmetrical transformation of a ellipse with respect
212 //! to the point P which is the center of the symmetry
213 Standard_NODISCARD Standard_EXPORT gp_Elips2d Mirrored (const gp_Pnt2d& P) const;
215 Standard_EXPORT void Mirror (const gp_Ax2d& A);
218 //! Performs the symmetrical transformation of a ellipse with respect
219 //! to an axis placement which is the axis of the symmetry.
220 Standard_NODISCARD Standard_EXPORT gp_Elips2d Mirrored (const gp_Ax2d& A) const;
222 void Rotate (const gp_Pnt2d& P, const Standard_Real Ang);
224 Standard_NODISCARD gp_Elips2d Rotated (const gp_Pnt2d& P, const Standard_Real Ang) const;
226 void Scale (const gp_Pnt2d& P, const Standard_Real S);
229 //! Scales a ellipse. S is the scaling value.
230 Standard_NODISCARD gp_Elips2d Scaled (const gp_Pnt2d& P, const Standard_Real S) const;
232 void Transform (const gp_Trsf2d& T);
235 //! Transforms an ellipse with the transformation T from class Trsf2d.
236 Standard_NODISCARD gp_Elips2d Transformed (const gp_Trsf2d& T) const;
238 void Translate (const gp_Vec2d& V);
241 //! Translates a ellipse in the direction of the vector V.
242 //! The magnitude of the translation is the vector's magnitude.
243 Standard_NODISCARD gp_Elips2d Translated (const gp_Vec2d& V) const;
245 void Translate (const gp_Pnt2d& P1, const gp_Pnt2d& P2);
248 //! Translates a ellipse from the point P1 to the point P2.
249 Standard_NODISCARD gp_Elips2d Translated (const gp_Pnt2d& P1, const gp_Pnt2d& P2) const;
265 Standard_Real majorRadius;
266 Standard_Real minorRadius;
272 #include <gp_Elips2d.lxx>
278 #endif // _gp_Elips2d_HeaderFile