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_Elips_HeaderFile
16 #define _gp_Elips_HeaderFile
18 #include <Standard.hxx>
19 #include <Standard_DefineAlloc.hxx>
20 #include <Standard_Handle.hxx>
23 #include <Standard_Real.hxx>
26 class Standard_ConstructionError;
35 //! Describes an ellipse in 3D space.
36 //! An ellipse is defined by its major and minor radii and
37 //! positioned in space with a coordinate system (a gp_Ax2 object) as follows:
38 //! - the origin of the coordinate system is the center of the ellipse,
39 //! - its "X Direction" defines the major axis of the ellipse, and
40 //! - its "Y Direction" defines the minor axis of the ellipse.
41 //! Together, the origin, "X Direction" and "Y Direction" of
42 //! this coordinate system define the plane of the ellipse.
43 //! This coordinate system is the "local coordinate system"
44 //! of the ellipse. In this coordinate system, the equation of
46 //! X*X / (MajorRadius**2) + Y*Y / (MinorRadius**2) = 1.0
47 //! The "main Direction" of the local coordinate system gives
48 //! the normal vector to the plane of the ellipse. This vector
49 //! gives an implicit orientation to the ellipse (definition of the
50 //! trigonometric sense). We refer to the "main Axis" of the
51 //! local coordinate system as the "Axis" of the ellipse.
53 //! gce_MakeElips which provides functions for more
54 //! complex ellipse constructions
55 //! Geom_Ellipse which provides additional functions for
56 //! constructing ellipses and works, in particular, with the
57 //! parametric equations of ellipses
65 //! Creates an indefinite ellipse.
69 //! The major radius of the ellipse is on the "XAxis" and the
70 //! minor radius is on the "YAxis" of the ellipse. The "XAxis"
71 //! is defined with the "XDirection" of A2 and the "YAxis" is
72 //! defined with the "YDirection" of A2.
74 //! It is not forbidden to create an ellipse with MajorRadius =
76 //! Raises ConstructionError if MajorRadius < MinorRadius or MinorRadius < 0.
77 gp_Elips(const gp_Ax2& A2, const Standard_Real MajorRadius, const Standard_Real MinorRadius);
80 //! Changes the axis normal to the plane of the ellipse.
81 //! It modifies the definition of this plane.
82 //! The "XAxis" and the "YAxis" are recomputed.
83 //! The local coordinate system is redefined so that:
84 //! - its origin and "main Direction" become those of the
85 //! axis A1 (the "X Direction" and "Y Direction" are then
86 //! recomputed in the same way as for any gp_Ax2), or
87 //! Raises ConstructionError if the direction of A1
88 //! is parallel to the direction of the "XAxis" of the ellipse.
89 void SetAxis (const gp_Ax1& A1);
91 //! Modifies this ellipse, by redefining its local coordinate
92 //! so that its origin becomes P.
93 void SetLocation (const gp_Pnt& P);
96 //! The major radius of the ellipse is on the "XAxis" (major axis)
98 //! Raises ConstructionError if MajorRadius < MinorRadius.
99 void SetMajorRadius (const Standard_Real MajorRadius);
102 //! The minor radius of the ellipse is on the "YAxis" (minor axis)
104 //! Raises ConstructionError if MinorRadius > MajorRadius or MinorRadius < 0.
105 void SetMinorRadius (const Standard_Real MinorRadius);
107 //! Modifies this ellipse, by redefining its local coordinate
108 //! so that it becomes A2e.
109 void SetPosition (const gp_Ax2& A2);
111 //! Computes the area of the Ellipse.
112 Standard_Real Area() const;
115 //! Computes the axis normal to the plane of the ellipse.
116 const gp_Ax1& Axis() const;
118 //! Computes the first or second directrix of this ellipse.
119 //! These are the lines, in the plane of the ellipse, normal to
120 //! the major axis, at a distance equal to
121 //! MajorRadius/e from the center of the ellipse, where
122 //! e is the eccentricity of the ellipse.
123 //! The first directrix (Directrix1) is on the positive side of
124 //! the major axis. The second directrix (Directrix2) is on
125 //! the negative side.
126 //! The directrix is returned as an axis (gp_Ax1 object), the
127 //! origin of which is situated on the "X Axis" of the local
128 //! coordinate system of this ellipse.
130 //! Standard_ConstructionError if the eccentricity is null
131 //! (the ellipse has degenerated into a circle).
132 gp_Ax1 Directrix1() const;
135 //! This line is obtained by the symmetrical transformation
136 //! of "Directrix1" with respect to the "YAxis" of the ellipse.
138 //! Standard_ConstructionError if the eccentricity is null
139 //! (the ellipse has degenerated into a circle).
140 gp_Ax1 Directrix2() const;
143 //! Returns the eccentricity of the ellipse between 0.0 and 1.0
144 //! If f is the distance between the center of the ellipse and
145 //! the Focus1 then the eccentricity e = f / MajorRadius.
146 //! Raises ConstructionError if MajorRadius = 0.0
147 Standard_Real Eccentricity() const;
150 //! Computes the focal distance. It is the distance between the
151 //! two focus focus1 and focus2 of the ellipse.
152 Standard_Real Focal() const;
155 //! Returns the first focus of the ellipse. This focus is on the
156 //! positive side of the "XAxis" of the ellipse.
157 gp_Pnt Focus1() const;
160 //! Returns the second focus of the ellipse. This focus is on the
161 //! negative side of the "XAxis" of the ellipse.
162 gp_Pnt Focus2() const;
165 //! Returns the center of the ellipse. It is the "Location"
166 //! point of the coordinate system of the ellipse.
167 const gp_Pnt& Location() const;
169 //! Returns the major radius of the ellipse.
170 Standard_Real MajorRadius() const;
172 //! Returns the minor radius of the ellipse.
173 Standard_Real MinorRadius() const;
176 //! Returns p = (1 - e * e) * MajorRadius where e is the eccentricity
178 //! Returns 0 if MajorRadius = 0
179 Standard_Real Parameter() const;
181 //! Returns the coordinate system of the ellipse.
182 const gp_Ax2& Position() const;
185 //! Returns the "XAxis" of the ellipse whose origin
186 //! is the center of this ellipse. It is the major axis of the
188 gp_Ax1 XAxis() const;
191 //! Returns the "YAxis" of the ellipse whose unit vector is the "X Direction" or the "Y Direction"
192 //! of the local coordinate system of this ellipse.
193 //! This is the minor axis of the ellipse.
194 gp_Ax1 YAxis() const;
196 Standard_EXPORT void Mirror (const gp_Pnt& P);
199 //! Performs the symmetrical transformation of an ellipse with
200 //! respect to the point P which is the center of the symmetry.
201 Standard_EXPORT Standard_NODISCARD gp_Elips Mirrored (const gp_Pnt& P) const;
203 Standard_EXPORT void Mirror (const gp_Ax1& A1);
206 //! Performs the symmetrical transformation of an ellipse with
207 //! respect to an axis placement which is the axis of the symmetry.
208 Standard_EXPORT Standard_NODISCARD gp_Elips Mirrored (const gp_Ax1& A1) const;
210 Standard_EXPORT void Mirror (const gp_Ax2& A2);
213 //! Performs the symmetrical transformation of an ellipse with
214 //! respect to a plane. The axis placement A2 locates the plane
215 //! of the symmetry (Location, XDirection, YDirection).
216 Standard_EXPORT Standard_NODISCARD gp_Elips Mirrored (const gp_Ax2& A2) const;
218 void Rotate (const gp_Ax1& A1, const Standard_Real Ang);
221 //! Rotates an ellipse. A1 is the axis of the rotation.
222 //! Ang is the angular value of the rotation in radians.
223 Standard_NODISCARD gp_Elips Rotated (const gp_Ax1& A1, const Standard_Real Ang) const;
225 void Scale (const gp_Pnt& P, const Standard_Real S);
228 //! Scales an ellipse. S is the scaling value.
229 Standard_NODISCARD gp_Elips Scaled (const gp_Pnt& P, const Standard_Real S) const;
231 void Transform (const gp_Trsf& T);
234 //! Transforms an ellipse with the transformation T from class Trsf.
235 Standard_NODISCARD gp_Elips Transformed (const gp_Trsf& T) const;
237 void Translate (const gp_Vec& V);
240 //! Translates an ellipse in the direction of the vector V.
241 //! The magnitude of the translation is the vector's magnitude.
242 Standard_NODISCARD gp_Elips Translated (const gp_Vec& V) const;
244 void Translate (const gp_Pnt& P1, const gp_Pnt& P2);
247 //! Translates an ellipse from the point P1 to the point P2.
248 Standard_NODISCARD gp_Elips Translated (const gp_Pnt& P1, const gp_Pnt& P2) const;
264 Standard_Real majorRadius;
265 Standard_Real minorRadius;
271 #include <gp_Elips.lxx>
277 #endif // _gp_Elips_HeaderFile