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_Parab2d_HeaderFile
16 #define _gp_Parab2d_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;
35 //! Describes a parabola in the plane (2D space).
36 //! A parabola is defined by its focal length (that is, the
37 //! distance between its focus and apex) and positioned in
38 //! the plane with a coordinate system (a gp_Ax22d object) where:
39 //! - the origin of the coordinate system is on the apex of
41 //! - the "X Axis" of the coordinate system is the axis of
42 //! symmetry; the parabola is on the positive side of this axis.
43 //! This coordinate system is the "local coordinate system"
44 //! of the parabola. Its orientation (direct or indirect sense)
45 //! gives an implicit orientation to the parabola.
46 //! In this coordinate system, the equation for the parabola is:
48 //! where P, referred to as the parameter of the parabola, is
49 //! the distance between the focus and the directrix (P is
50 //! twice the focal length).
52 //! GCE2d_MakeParab2d which provides functions for
53 //! more complex parabola constructions
54 //! Geom2d_Parabola which provides additional functions
55 //! for constructing parabolas and works, in particular, with
56 //! the parametric equations of parabolas
64 //! Creates an indefinite parabola.
68 //! Creates a parabola with its vertex point, its axis of symmetry
69 //! ("XAxis") and its focal length.
70 //! The sense of parametrization is given by theSense. If theSense == TRUE
71 //! (by default) then right-handed coordinate system is used,
72 //! otherwise - left-handed.
73 //! Warnings : It is possible to have FocalLength = 0. In this case,
74 //! the parabola looks like a line, which is parallel to the symmetry-axis.
75 //! Raises ConstructionError if FocalLength < 0.0
76 gp_Parab2d(const gp_Ax2d& theMirrorAxis,
77 const Standard_Real theFocalLength,
78 const Standard_Boolean theSense = Standard_True);
81 //! Creates a parabola with its vertex point, its axis of symmetry
82 //! ("XAxis"), correspond Y-axis and its focal length.
83 //! Warnings : It is possible to have FocalLength = 0. In this case,
84 //! the parabola looks like a line, which is parallel to the symmetry-axis.
85 //! Raises ConstructionError if Focal < 0.0
86 gp_Parab2d(const gp_Ax22d& theAxes, const Standard_Real theFocalLength);
89 //! Creates a parabola with the directrix and the focus point.
90 //! Y-axis of the parabola (in User Coordinate System - UCS) is
91 //! the direction of theDirectrix. X-axis always directs from theDirectrix
92 //! to theFocus point and always comes through theFocus.
93 //! Apex of the parabola is a middle point between the theFocus and the
94 //! intersection point of theDirectrix and the X-axis.
95 //! Warnings : It is possible to have FocalLength = 0 (when theFocus lies
96 //! in theDirectrix). In this case, X-direction of the parabola is defined
97 //! by theSense parameter. If theSense == TRUE (by default) then right-handed
98 //! coordinate system is used, otherwise - left-handed. Result parabola will look
99 //! like a line, which is perpendicular to the directrix.
100 Standard_EXPORT gp_Parab2d(const gp_Ax2d& theDirectrix,
101 const gp_Pnt2d& theFocus,
102 const Standard_Boolean theSense = Standard_True);
104 //! Changes the focal distance of the parabola
105 //! Warnings : It is possible to have Focal = 0.
106 //! Raises ConstructionError if Focal < 0.0
107 void SetFocal (const Standard_Real Focal);
110 //! Changes the "Location" point of the parabola. It is the
111 //! vertex of the parabola.
112 void SetLocation (const gp_Pnt2d& P);
114 //! Modifies this parabola, by redefining its local coordinate system so that
115 //! its origin and "X Direction" become those of the axis
116 //! MA. The "Y Direction" of the local coordinate system is
117 //! then recomputed. The orientation of the local
118 //! coordinate system is not modified.
119 void SetMirrorAxis (const gp_Ax2d& A);
122 //! Changes the local coordinate system of the parabola.
123 //! The "Location" point of A becomes the vertex of the parabola.
124 void SetAxis (const gp_Ax22d& A);
127 //! Computes the coefficients of the implicit equation of the parabola
128 //! (in WCS - World Coordinate System).
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,
131 Standard_Real& C, Standard_Real& D,
132 Standard_Real& E, Standard_Real& F) const;
135 //! Computes the directrix of the parabola.
136 //! The directrix is:
137 //! - a line parallel to the "Y Direction" of the local
138 //! coordinate system of this parabola, and
139 //! - located on the negative side of the axis of symmetry,
140 //! at a distance from the apex which is equal to the focal length of this parabola.
141 //! The directrix is returned as an axis (a gp_Ax2d object),
142 //! the origin of which is situated on the "X Axis" of this parabola.
143 gp_Ax2d Directrix() const;
146 //! Returns the distance between the vertex and the focus
148 Standard_Real Focal() const;
150 //! Returns the focus of the parabola.
151 gp_Pnt2d Focus() const;
153 //! Returns the vertex of the parabola.
154 gp_Pnt2d Location() const;
157 //! Returns the symmetry axis of the parabola.
158 //! The "Location" point of this axis is the vertex of the parabola.
159 gp_Ax2d MirrorAxis() const;
162 //! Returns the local coordinate system of the parabola.
163 //! The "Location" point of this axis is the vertex of the parabola.
164 gp_Ax22d Axis() const;
167 //! Returns the distance between the focus and the
168 //! directrix of the parabola.
169 Standard_Real Parameter() const;
174 //! Reverses the orientation of the local coordinate system
175 //! of this parabola (the "Y Direction" is reversed).
176 //! Therefore, the implicit orientation of this parabola is reversed.
178 //! - Reverse assigns the result to this parabola, while
179 //! - Reversed creates a new one.
180 Standard_NODISCARD gp_Parab2d Reversed() const;
182 //! Returns true if the local coordinate system is direct
183 //! and false in the other case.
184 Standard_Boolean IsDirect() const;
186 Standard_EXPORT void Mirror (const gp_Pnt2d& P);
189 //! Performs the symmetrical transformation of a parabola with respect
190 //! to the point P which is the center of the symmetry
191 Standard_NODISCARD Standard_EXPORT gp_Parab2d Mirrored (const gp_Pnt2d& P) const;
193 Standard_EXPORT void Mirror (const gp_Ax2d& A);
196 //! Performs the symmetrical transformation of a parabola with respect
197 //! to an axis placement which is the axis of the symmetry.
198 Standard_NODISCARD Standard_EXPORT gp_Parab2d Mirrored (const gp_Ax2d& A) const;
200 void Rotate (const gp_Pnt2d& P, const Standard_Real Ang);
203 //! Rotates a parabola. P is the center of the rotation.
204 //! Ang is the angular value of the rotation in radians.
205 Standard_NODISCARD gp_Parab2d Rotated (const gp_Pnt2d& P, const Standard_Real Ang) const;
207 void Scale (const gp_Pnt2d& P, const Standard_Real S);
210 //! Scales a parabola. S is the scaling value.
211 //! If S is negative the direction of the symmetry axis
212 //! "XAxis" is reversed and the direction of the "YAxis" too.
213 Standard_NODISCARD gp_Parab2d Scaled (const gp_Pnt2d& P, const Standard_Real S) const;
215 void Transform (const gp_Trsf2d& T);
218 //! Transforms an parabola with the transformation T from class Trsf2d.
219 Standard_NODISCARD gp_Parab2d Transformed (const gp_Trsf2d& T) const;
221 void Translate (const gp_Vec2d& V);
224 //! Translates a parabola in the direction of the vector V.
225 //! The magnitude of the translation is the vector's magnitude.
226 Standard_NODISCARD gp_Parab2d Translated (const gp_Vec2d& V) const;
228 void Translate (const gp_Pnt2d& P1, const gp_Pnt2d& P2);
231 //! Translates a parabola from the point P1 to the point P2.
232 Standard_NODISCARD gp_Parab2d Translated (const gp_Pnt2d& P1, const gp_Pnt2d& P2) const;
248 Standard_Real focalLength;
254 #include <gp_Parab2d.lxx>
260 #endif // _gp_Parab2d_HeaderFile