1 // Created on: 1993-03-10
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 _Geom_Ellipse_HeaderFile
18 #define _Geom_Ellipse_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <Standard_Real.hxx>
24 #include <Geom_Conic.hxx>
25 #include <Standard_Boolean.hxx>
26 #include <Standard_Integer.hxx>
37 DEFINE_STANDARD_HANDLE(Geom_Ellipse, Geom_Conic)
39 //! Describes an ellipse in 3D space.
40 //! An ellipse is defined by its major and minor radii and,
41 //! as with any conic curve, is positioned in space with a
42 //! right-handed coordinate system (gp_Ax2 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 //! The origin, "X Direction" and "Y Direction" of this
47 //! coordinate system define the plane of the ellipse. The
48 //! coordinate system is the local coordinate system of the ellipse.
49 //! The "main Direction" of this coordinate system is the
50 //! vector normal to the plane of the ellipse. The axis, of
51 //! which the origin and unit vector are respectively the
52 //! origin and "main Direction" of the local coordinate
53 //! system, is termed the "Axis" or "main Axis" of the ellipse.
54 //! The "main Direction" of the local coordinate system
55 //! gives an explicit orientation to the ellipse (definition of
56 //! the trigonometric sense), determining the direction in
57 //! which the parameter increases along the ellipse.
58 //! The Geom_Ellipse ellipse is parameterized by an angle:
59 //! P(U) = O + MajorRad*Cos(U)*XDir + MinorRad*Sin(U)*YDir
61 //! - P is the point of parameter U,
62 //! - O, XDir and YDir are respectively the origin, "X
63 //! Direction" and "Y Direction" of its local coordinate system,
64 //! - MajorRad and MinorRad are the major and minor radii of the ellipse.
65 //! The "X Axis" of the local coordinate system therefore
66 //! defines the origin of the parameter of the ellipse.
67 //! An ellipse is a closed and periodic curve. The period
68 //! is 2.*Pi and the parameter range is [ 0, 2.*Pi [.
69 class Geom_Ellipse : public Geom_Conic
75 //! Constructs an ellipse by conversion of the gp_Elips ellipse E.
76 Standard_EXPORT Geom_Ellipse(const gp_Elips& E);
78 //! Constructs an ellipse
79 //! defined by its major and minor radii, MajorRadius
80 //! and MinorRadius, where A2 locates the ellipse
81 //! and defines its orientation in 3D space such that:
82 //! - the center of the ellipse is the origin of A2,
83 //! - the "X Direction" of A2 defines the major axis
84 //! of the ellipse, i.e. the major radius
85 //! MajorRadius is measured along this axis,
86 //! - the "Y Direction" of A2 defines the minor axis
87 //! of the ellipse, i.e. the minor radius
88 //! MinorRadius is measured along this axis,
89 //! - A2 is the local coordinate system of the ellipse.
91 //! Standard_ConstructionError if:
92 //! - MajorRadius is less than MinorRadius, or
93 //! - MinorRadius is less than 0.
94 //! Warning The Geom package does not prevent the
95 //! construction of an ellipse where MajorRadius and
96 //! MinorRadius are equal.
97 Standard_EXPORT Geom_Ellipse(const gp_Ax2& A2, const Standard_Real MajorRadius, const Standard_Real MinorRadius);
99 //! Converts the gp_Elips ellipse E into this ellipse.
100 Standard_EXPORT void SetElips (const gp_Elips& E);
102 //! Assigns a value to the major radius of this ellipse.
103 //! ConstructionError raised if MajorRadius < MinorRadius.
104 Standard_EXPORT void SetMajorRadius (const Standard_Real MajorRadius);
106 //! Assigns a value to the minor radius of this ellipse.
107 //! ConstructionError raised if MajorRadius < MinorRadius or if MinorRadius < 0.
108 Standard_EXPORT void SetMinorRadius (const Standard_Real MinorRadius);
111 //! returns the non transient ellipse from gp with the same
112 Standard_EXPORT gp_Elips Elips() const;
114 //! Computes the parameter on the reversed ellipse for
115 //! the point of parameter U on this ellipse.
116 //! For an ellipse, the returned value is: 2.*Pi - U.
117 Standard_EXPORT Standard_Real ReversedParameter (const Standard_Real U) const Standard_OVERRIDE;
120 //! This directrix is the line normal to the XAxis of the ellipse
121 //! in the local plane (Z = 0) at a distance d = MajorRadius / e
122 //! from the center of the ellipse, where e is the eccentricity of
124 //! This line is parallel to the "YAxis". The intersection point
125 //! between directrix1 and the "XAxis" is the "Location" point
126 //! of the directrix1. This point is on the positive side of
128 //! Raised if Eccentricity = 0.0. (The ellipse degenerates
130 Standard_EXPORT gp_Ax1 Directrix1() const;
133 //! This line is obtained by the symmetrical transformation
134 //! of "Directrix1" with respect to the "YAxis" of the ellipse.
136 //! Raised if Eccentricity = 0.0. (The ellipse degenerates into a
138 Standard_EXPORT gp_Ax1 Directrix2() const;
141 //! Returns the eccentricity of the ellipse between 0.0 and 1.0
142 //! If f is the distance between the center of the ellipse and
143 //! the Focus1 then the eccentricity e = f / MajorRadius.
144 //! Returns 0 if MajorRadius = 0
145 Standard_EXPORT Standard_Real Eccentricity() const Standard_OVERRIDE;
148 //! Computes the focal distance. It is the distance between the
149 //! the two focus of the ellipse.
150 Standard_EXPORT Standard_Real Focal() const;
153 //! Returns the first focus of the ellipse. This focus is on the
154 //! positive side of the "XAxis" of the ellipse.
155 Standard_EXPORT gp_Pnt Focus1() const;
158 //! Returns the second focus of the ellipse. This focus is on
159 //! the negative side of the "XAxis" of the ellipse.
160 Standard_EXPORT gp_Pnt Focus2() const;
162 //! Returns the major radius of this ellipse.
163 Standard_EXPORT Standard_Real MajorRadius() const;
165 //! Returns the minor radius of this ellipse.
166 Standard_EXPORT Standard_Real MinorRadius() const;
169 //! Returns p = (1 - e * e) * MajorRadius where e is the eccentricity
171 //! Returns 0 if MajorRadius = 0
172 Standard_EXPORT Standard_Real Parameter() const;
174 //! Returns the value of the first parameter of this
175 //! ellipse. This is respectively:
176 //! - 0.0, which gives the start point of this ellipse, or
177 //! The start point and end point of an ellipse are coincident.
178 Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE;
180 //! Returns the value of the last parameter of this
181 //! ellipse. This is respectively:
182 //! - 2.*Pi, which gives the end point of this ellipse.
183 //! The start point and end point of an ellipse are coincident.
184 Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE;
187 Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE;
190 Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE;
192 //! Returns in P the point of parameter U.
193 //! P = C + MajorRadius * Cos (U) * XDir + MinorRadius * Sin (U) * YDir
194 //! where C is the center of the ellipse , XDir the direction of
195 //! the "XAxis" and "YDir" the "YAxis" of the ellipse.
196 Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt& P) const Standard_OVERRIDE;
198 Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1) const Standard_OVERRIDE;
201 //! Returns the point P of parameter U. The vectors V1 and V2
202 //! are the first and second derivatives at this point.
203 Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const Standard_OVERRIDE;
206 //! Returns the point P of parameter U, the first second and
207 //! third derivatives V1 V2 and V3.
208 Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const Standard_OVERRIDE;
210 //! For the point of parameter U of this ellipse, computes
211 //! the vector corresponding to the Nth derivative.
212 //! Exceptions Standard_RangeError if N is less than 1.
213 Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE;
215 //! Applies the transformation T to this ellipse.
216 Standard_EXPORT void Transform (const gp_Trsf& T) Standard_OVERRIDE;
218 //! Creates a new object which is a copy of this ellipse.
219 Standard_EXPORT Handle(Geom_Geometry) Copy() const Standard_OVERRIDE;
221 //! Dumps the content of me into the stream
222 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
227 DEFINE_STANDARD_RTTIEXT(Geom_Ellipse,Geom_Conic)
237 Standard_Real majorRadius;
238 Standard_Real minorRadius;
249 #endif // _Geom_Ellipse_HeaderFile