1 // Created on: 1993-03-24
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Geom2d_Ellipse_HeaderFile
18 #define _Geom2d_Ellipse_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <Standard_Real.hxx>
24 #include <Geom2d_Conic.hxx>
25 #include <Standard_Boolean.hxx>
26 #include <Standard_Integer.hxx>
33 class Geom2d_Geometry;
37 DEFINE_STANDARD_HANDLE(Geom2d_Ellipse, Geom2d_Conic)
39 //! Describes an ellipse in the plane (2D space).
40 //! An ellipse is defined by its major and minor radii and,
41 //! as with any conic curve, is positioned in the plane
42 //! with a coordinate system (gp_Ax22d object) where:
43 //! - the origin is the center of the ellipse,
44 //! - the "X Direction" defines the major axis, and
45 //! - the "Y Direction" defines the minor axis.
46 //! This coordinate system is the local coordinate system of the ellipse.
47 //! The orientation (direct or indirect) of the local
48 //! coordinate system gives an explicit orientation to the
49 //! ellipse, determining the direction in which the
50 //! parameter increases along the ellipse.
51 //! The Geom2d_Ellipse ellipse is parameterized by an angle:
52 //! P(U) = O + MajorRad*Cos(U)*XDir + MinorRad*Sin(U)*YDir
54 //! - P is the point of parameter U,
55 //! - O, XDir and YDir are respectively the origin, "X
56 //! Direction" and "Y Direction" of its local coordinate system,
57 //! - MajorRad and MinorRad are the major and
58 //! minor radii of the ellipse.
59 //! The "X Axis" of the local coordinate system therefore
60 //! defines the origin of the parameter of the ellipse.
61 //! An ellipse is a closed and periodic curve. The period
62 //! is 2.*Pi and the parameter range is [ 0,2.*Pi [.
64 //! GCE2d_MakeEllipse which provides functions for
65 //! more complex ellipse constructions
67 //! gp_Elips2d for an equivalent, non-parameterized data structure
68 class Geom2d_Ellipse : public Geom2d_Conic
75 //! Creates an ellipse by conversion of the gp_Elips2d ellipse E.
76 Standard_EXPORT Geom2d_Ellipse(const gp_Elips2d& E);
78 //! Creates an ellipse defined by its major and minor radii,
79 //! MajorRadius and MinorRadius, and positioned
80 //! in the plane by its major axis MajorAxis; the
81 //! center of the ellipse is the origin of MajorAxis
82 //! and the unit vector of MajorAxis is the "X
83 //! Direction" of the local coordinate system of the
84 //! ellipse; this coordinate system is direct if Sense
85 //! is true (default value) or indirect if Sense is false.
87 //! It is not forbidden to create an ellipse with MajorRadius =
90 //! Standard_ConstructionError if:
91 //! - MajorRadius is less than MinorRadius, or
92 //! - MinorRadius is less than 0.
93 Standard_EXPORT Geom2d_Ellipse(const gp_Ax2d& MajorAxis, const Standard_Real MajorRadius, const Standard_Real MinorRadius, const Standard_Boolean Sense = Standard_True);
95 //! Creates an ellipse defined by its major and minor radii,
96 //! MajorRadius and MinorRadius, where the
97 //! coordinate system Axis locates the ellipse and
98 //! defines its orientation in the plane such that:
99 //! - the center of the ellipse is the origin of Axis,
100 //! - the "X Direction" of Axis defines the major
101 //! axis of the ellipse,
102 //! - the "Y Direction" of Axis defines the minor
103 //! axis of the ellipse,
104 //! - the orientation of Axis (direct or indirect)
105 //! gives the orientation of the ellipse.
107 //! It is not forbidden to create an ellipse with MajorRadius =
110 //! Standard_ConstructionError if:
111 //! - MajorRadius is less than MinorRadius, or
112 //! - MinorRadius is less than 0.
113 Standard_EXPORT Geom2d_Ellipse(const gp_Ax22d& Axis, const Standard_Real MajorRadius, const Standard_Real MinorRadius);
115 //! Converts the gp_Elips2d ellipse E into this ellipse.
116 Standard_EXPORT void SetElips2d (const gp_Elips2d& E);
118 //! Assigns a value to the major radius of this ellipse.
120 //! Standard_ConstructionError if:
121 //! - the major radius of this ellipse becomes less than
122 //! the minor radius, or
123 //! - MinorRadius is less than 0.
124 Standard_EXPORT void SetMajorRadius (const Standard_Real MajorRadius);
126 //! Assigns a value to the minor radius of this ellipse.
128 //! Standard_ConstructionError if:
129 //! - the major radius of this ellipse becomes less than
130 //! the minor radius, or
131 //! - MinorRadius is less than 0.
132 Standard_EXPORT void SetMinorRadius (const Standard_Real MinorRadius);
134 //! Converts this ellipse into a gp_Elips2d ellipse.
135 Standard_EXPORT gp_Elips2d Elips2d() const;
137 //! Computes the parameter on the reversed ellipse for
138 //! the point of parameter U on this ellipse.
139 //! For an ellipse, the returned value is: 2.*Pi - U.
140 Standard_EXPORT Standard_Real ReversedParameter (const Standard_Real U) const Standard_OVERRIDE;
142 //! Computes the directrices of this ellipse.
143 //! This directrix is the line normal to the XAxis of the ellipse
144 //! in the local plane (Z = 0) at a distance d = MajorRadius / e
145 //! from the center of the ellipse, where e is the eccentricity of
147 //! This line is parallel to the "YAxis". The intersection point
148 //! between directrix1 and the "XAxis" is the "Location" point
149 //! of the directrix1. This point is on the positive side of
151 //! Raises ConstructionError if Eccentricity = 0.0. (The ellipse degenerates
153 Standard_EXPORT gp_Ax2d Directrix1() const;
156 //! This line is obtained by the symmetrical transformation
157 //! of "Directrix1" with respect to the "YAxis" of the ellipse.
158 //! Raises ConstructionError if Eccentricity = 0.0. (The ellipse degenerates into a
160 Standard_EXPORT gp_Ax2d Directrix2() const;
163 //! Returns the eccentricity of the ellipse between 0.0 and 1.0
164 //! If f is the distance between the center of the ellipse and
165 //! the Focus1 then the eccentricity e = f / MajorRadius.
166 //! Returns 0 if MajorRadius = 0
167 Standard_EXPORT Standard_Real Eccentricity() const Standard_OVERRIDE;
170 //! Computes the focal distance. The focal distance is the distance between the center
171 //! and a focus of the ellipse.
172 Standard_EXPORT Standard_Real Focal() const;
175 //! Returns the first focus of the ellipse. This focus is on the
176 //! positive side of the "XAxis" of the ellipse.
177 Standard_EXPORT gp_Pnt2d Focus1() const;
180 //! Returns the second focus of the ellipse. This focus is on
181 //! the negative side of the "XAxis" of the ellipse.
182 Standard_EXPORT gp_Pnt2d Focus2() const;
184 //! Returns the major radius of this ellipse.
185 Standard_EXPORT Standard_Real MajorRadius() const;
187 //! Returns the minor radius of this ellipse.
188 Standard_EXPORT Standard_Real MinorRadius() const;
191 //! Computes the parameter of this ellipse. This value is
192 //! given by the formula p = (1 - e * e) * MajorRadius where e is the eccentricity
194 //! Returns 0 if MajorRadius = 0
195 Standard_EXPORT Standard_Real Parameter() const;
197 //! Returns the value of the first parameter of this
198 //! ellipse. This is 0.0, which gives the start point of this ellipse.
199 //! The start point and end point of an ellipse are coincident.
200 Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE;
202 //! Returns the value of the last parameter of this
203 //! ellipse. This is 2.*Pi, which gives the end point of this ellipse.
204 //! The start point and end point of an ellipse are coincident.
205 Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE;
208 Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE;
211 Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE;
213 //! Returns in P the point of parameter U.
214 //! P = C + MajorRadius * Cos (U) * XDir + MinorRadius * Sin (U) * YDir
215 //! where C is the center of the ellipse , XDir the direction of
216 //! the "XAxis" and "YDir" the "YAxis" of the ellipse.
217 Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt2d& P) const Standard_OVERRIDE;
219 Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1) const Standard_OVERRIDE;
222 //! Returns the point P of parameter U. The vectors V1 and V2
223 //! are the first and second derivatives at this point.
224 Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const Standard_OVERRIDE;
227 //! Returns the point P of parameter U, the first second and
228 //! third derivatives V1 V2 and V3.
229 Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const Standard_OVERRIDE;
231 //! For the point of parameter U of this ellipse,
232 //! computes the vector corresponding to the Nth derivative.
233 //! Exceptions Standard_RangeError if N is less than 1.
234 Standard_EXPORT gp_Vec2d DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE;
236 //! Applies the transformation T to this ellipse.
237 Standard_EXPORT void Transform (const gp_Trsf2d& T) Standard_OVERRIDE;
239 //! Creates a new object which is a copy of this ellipse.
240 Standard_EXPORT Handle(Geom2d_Geometry) Copy() const Standard_OVERRIDE;
242 //! Dumps the content of me into the stream
243 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
248 DEFINE_STANDARD_RTTIEXT(Geom2d_Ellipse,Geom2d_Conic)
258 Standard_Real majorRadius;
259 Standard_Real minorRadius;
270 #endif // _Geom2d_Ellipse_HeaderFile