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_Circ2d_HeaderFile
16 #define _gp_Circ2d_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 class Standard_ConstructionError;
34 //! Describes a circle in the plane (2D space).
35 //! A circle is defined by its radius and positioned in the
36 //! plane with a coordinate system (a gp_Ax22d object) as follows:
37 //! - the origin of the coordinate system is the center of the circle, and
38 //! - the orientation (direct or indirect) of the coordinate
39 //! system gives an implicit orientation to the circle (and
40 //! defines its trigonometric sense).
41 //! This positioning coordinate system is the "local
42 //! coordinate system" of the circle.
43 //! Note: when a gp_Circ2d circle is converted into a
44 //! Geom2d_Circle circle, some implicit properties of the
45 //! circle are used explicitly:
46 //! - the implicit orientation corresponds to the direction in
47 //! which parameter values increase,
48 //! - the starting point for parameterization is that of the "X
49 //! Axis" of the local coordinate system (i.e. the "X Axis" of the circle).
51 //! GccAna and Geom2dGcc packages which provide
52 //! functions for constructing circles defined by geometric constraints
53 //! gce_MakeCirc2d which provides functions for more
54 //! complex circle constructions
55 //! Geom2d_Circle which provides additional functions for
56 //! constructing circles and works, with the parametric
57 //! equations of circles in particular gp_Ax22d
65 //! creates an indefinite circle.
69 //! The location point of XAxis is the center of the circle.
71 //! It is not forbidden to create a circle with Radius = 0.0 Raises ConstructionError if Radius < 0.0.
72 //! Raised if Radius < 0.0.
73 gp_Circ2d(const gp_Ax2d& XAxis, const Standard_Real Radius, const Standard_Boolean Sense = Standard_True);
76 //! Axis defines the Xaxis and Yaxis of the circle which defines
77 //! the origin and the sense of parametrization.
78 //! The location point of Axis is the center of the circle.
80 //! It is not forbidden to create a circle with Radius = 0.0 Raises ConstructionError if Radius < 0.0.
81 //! Raised if Radius < 0.0.
82 gp_Circ2d(const gp_Ax22d& Axis, const Standard_Real Radius);
84 //! Changes the location point (center) of the circle.
85 Standard_EXPORT void SetLocation (const gp_Pnt2d& P);
87 //! Changes the X axis of the circle.
88 void SetXAxis (const gp_Ax2d& A);
90 //! Changes the X axis of the circle.
91 void SetAxis (const gp_Ax22d& A);
93 //! Changes the Y axis of the circle.
94 void SetYAxis (const gp_Ax2d& A);
96 //! Modifies the radius of this circle.
97 //! This class does not prevent the creation of a circle where
100 //! Standard_ConstructionError if Radius is negative.
101 void SetRadius (const Standard_Real Radius);
103 //! Computes the area of the circle.
104 Standard_Real Area() const;
107 //! Returns the normalized coefficients from the implicit equation
109 //! A * (X**2) + B * (Y**2) + 2*C*(X*Y) + 2*D*X + 2*E*Y + F = 0.0
110 void Coefficients (Standard_Real& A, Standard_Real& B, Standard_Real& C, Standard_Real& D, Standard_Real& E, Standard_Real& F) const;
112 //! Does <me> contain P ?
113 //! Returns True if the distance between P and any point on
114 //! the circumference of the circle is lower of equal to
115 //! <LinearTolerance>.
116 Standard_Boolean Contains (const gp_Pnt2d& P, const Standard_Real LinearTolerance) const;
119 //! Computes the minimum of distance between the point P and any
120 //! point on the circumference of the circle.
121 Standard_Real Distance (const gp_Pnt2d& P) const;
124 //! Computes the square distance between <me> and the point P.
125 Standard_Real SquareDistance (const gp_Pnt2d& P) const;
127 //! computes the circumference of the circle.
128 Standard_Real Length() const;
130 //! Returns the location point (center) of the circle.
131 const gp_Pnt2d& Location() const;
133 //! Returns the radius value of the circle.
134 Standard_Real Radius() const;
136 //! returns the position of the circle.
137 const gp_Ax22d& Axis() const;
139 //! returns the position of the circle. Idem Axis(me).
140 const gp_Ax22d& Position() const;
142 //! returns the X axis of the circle.
143 gp_Ax2d XAxis() const;
145 //! Returns the Y axis of the circle.
146 //! Reverses the direction of the circle.
147 gp_Ax2d YAxis() const;
149 //! Reverses the orientation of the local coordinate system
150 //! of this circle (the "Y Direction" is reversed) and therefore
151 //! changes the implicit orientation of this circle.
152 //! Reverse assigns the result to this circle,
155 //! Reverses the orientation of the local coordinate system
156 //! of this circle (the "Y Direction" is reversed) and therefore
157 //! changes the implicit orientation of this circle.
158 //! Reversed creates a new circle.
159 gp_Circ2d Reversed() const;
161 //! Returns true if the local coordinate system is direct
162 //! and false in the other case.
163 Standard_Boolean IsDirect() const;
165 Standard_EXPORT void Mirror (const gp_Pnt2d& P);
168 //! Performs the symmetrical transformation of a circle with respect
169 //! to the point P which is the center of the symmetry
170 Standard_EXPORT gp_Circ2d Mirrored (const gp_Pnt2d& P) const;
172 Standard_EXPORT void Mirror (const gp_Ax2d& A);
175 //! Performs the symmetrical transformation of a circle with respect
176 //! to an axis placement which is the axis of the symmetry.
177 Standard_EXPORT gp_Circ2d Mirrored (const gp_Ax2d& A) const;
179 void Rotate (const gp_Pnt2d& P, const Standard_Real Ang);
182 //! Rotates a circle. P is the center of the rotation.
183 //! Ang is the angular value of the rotation in radians.
184 gp_Circ2d Rotated (const gp_Pnt2d& P, const Standard_Real Ang) const;
186 void Scale (const gp_Pnt2d& P, const Standard_Real S);
189 //! Scales a circle. S is the scaling value.
191 //! If S is negative the radius stay positive but
192 //! the "XAxis" and the "YAxis" are reversed as for
194 gp_Circ2d Scaled (const gp_Pnt2d& P, const Standard_Real S) const;
196 void Transform (const gp_Trsf2d& T);
199 //! Transforms a circle with the transformation T from class Trsf2d.
200 gp_Circ2d Transformed (const gp_Trsf2d& T) const;
202 void Translate (const gp_Vec2d& V);
205 //! Translates a circle in the direction of the vector V.
206 //! The magnitude of the translation is the vector's magnitude.
207 gp_Circ2d Translated (const gp_Vec2d& V) const;
209 void Translate (const gp_Pnt2d& P1, const gp_Pnt2d& P2);
212 //! Translates a circle from the point P1 to the point P2.
213 gp_Circ2d Translated (const gp_Pnt2d& P1, const gp_Pnt2d& P2) const;
229 Standard_Real radius;
235 #include <gp_Circ2d.lxx>
241 #endif // _gp_Circ2d_HeaderFile