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_Circ_HeaderFile
16 #define _gp_Circ_HeaderFile
18 #include <Standard.hxx>
19 #include <Standard_DefineAlloc.hxx>
20 #include <Standard_Handle.hxx>
23 #include <Standard_Real.hxx>
25 #include <Standard_Boolean.hxx>
26 class Standard_ConstructionError;
35 //! Describes a circle in 3D space.
36 //! A circle is defined by its radius and positioned in space
37 //! with a coordinate system (a gp_Ax2 object) as follows:
38 //! - the origin of the coordinate system is the center of the circle, and
39 //! - the origin, "X Direction" and "Y Direction" of the
40 //! coordinate system define the plane of the circle.
41 //! This positioning coordinate system is the "local
42 //! coordinate system" of the circle. Its "main Direction"
43 //! gives the normal vector to the plane of the circle. The
44 //! "main Axis" of the coordinate system is referred to as
45 //! the "Axis" of the circle.
46 //! Note: when a gp_Circ circle is converted into a
47 //! Geom_Circle circle, some implicit properties of the
48 //! circle are used explicitly:
49 //! - the "main Direction" of the local coordinate system
50 //! gives an implicit orientation to the circle (and defines
51 //! its trigonometric sense),
52 //! - this orientation corresponds to the direction in
53 //! which parameter values increase,
54 //! - the starting point for parameterization is that of the
55 //! "X Axis" of the local coordinate system (i.e. the "X Axis" of the circle).
57 //! gce_MakeCirc which provides functions for more complex circle constructions
58 //! Geom_Circle which provides additional functions for
59 //! constructing circles and works, in particular, with the
60 //! parametric equations of circles
68 //! Creates an indefinite circle.
72 //! A2 locates the circle and gives its orientation in 3D space.
74 //! It is not forbidden to create a circle with Radius = 0.0 Raises ConstructionError if Radius < 0.0
75 gp_Circ(const gp_Ax2& A2, const Standard_Real Radius);
78 //! Changes the main axis of the circle. It is the axis
79 //! perpendicular to the plane of the circle.
80 //! Raises ConstructionError if the direction of A1
81 //! is parallel to the "XAxis" of the circle.
82 void SetAxis (const gp_Ax1& A1);
85 //! Changes the "Location" point (center) of the circle.
86 void SetLocation (const gp_Pnt& P);
88 //! Changes the position of the circle.
89 void SetPosition (const gp_Ax2& A2);
91 //! Modifies the radius of this circle.
92 //! Warning. This class does not prevent the creation of a circle where Radius is null.
94 //! Standard_ConstructionError if Radius is negative.
95 void SetRadius (const Standard_Real Radius);
97 //! Computes the area of the circle.
98 Standard_Real Area() const;
101 //! Returns the main axis of the circle.
102 //! It is the axis perpendicular to the plane of the circle,
103 //! passing through the "Location" point (center) of the circle.
104 const gp_Ax1& Axis() const;
106 //! Computes the circumference of the circle.
107 Standard_Real Length() const;
110 //! Returns the center of the circle. It is the
111 //! "Location" point of the local coordinate system
113 const gp_Pnt& Location() const;
116 //! Returns the position of the circle.
117 //! It is the local coordinate system of the circle.
118 const gp_Ax2& Position() const;
120 //! Returns the radius of this circle.
121 Standard_Real Radius() const;
124 //! Returns the "XAxis" of the circle.
125 //! This axis is perpendicular to the axis of the conic.
126 //! This axis and the "Yaxis" define the plane of the conic.
127 gp_Ax1 XAxis() const;
130 //! Returns the "YAxis" of the circle.
131 //! This axis and the "Xaxis" define the plane of the conic.
132 //! The "YAxis" is perpendicular to the "Xaxis".
133 gp_Ax1 YAxis() const;
136 //! Computes the minimum of distance between the point P and
137 //! any point on the circumference of the circle.
138 Standard_Real Distance (const gp_Pnt& P) const;
141 //! Computes the square distance between <me> and the point P.
142 Standard_Real SquareDistance (const gp_Pnt& P) const;
145 //! Returns True if the point P is on the circumference.
146 //! The distance between <me> and <P> must be lower or
147 //! equal to LinearTolerance.
148 Standard_Boolean Contains (const gp_Pnt& P, const Standard_Real LinearTolerance) const;
150 Standard_EXPORT void Mirror (const gp_Pnt& P);
153 //! Performs the symmetrical transformation of a circle
154 //! with respect to the point P which is the center of the
156 Standard_EXPORT Standard_NODISCARD gp_Circ Mirrored (const gp_Pnt& P) const;
158 Standard_EXPORT void Mirror (const gp_Ax1& A1);
161 //! Performs the symmetrical transformation of a circle with
162 //! respect to an axis placement which is the axis of the
164 Standard_EXPORT Standard_NODISCARD gp_Circ Mirrored (const gp_Ax1& A1) const;
166 Standard_EXPORT void Mirror (const gp_Ax2& A2);
169 //! Performs the symmetrical transformation of a circle with respect
170 //! to a plane. The axis placement A2 locates the plane of the
171 //! of the symmetry : (Location, XDirection, YDirection).
172 Standard_EXPORT Standard_NODISCARD gp_Circ Mirrored (const gp_Ax2& A2) const;
174 void Rotate (const gp_Ax1& A1, const Standard_Real Ang);
177 //! Rotates a circle. A1 is the axis of the rotation.
178 //! Ang is the angular value of the rotation in radians.
179 Standard_NODISCARD gp_Circ Rotated (const gp_Ax1& A1, const Standard_Real Ang) const;
181 void Scale (const gp_Pnt& P, const Standard_Real S);
184 //! Scales a circle. S is the scaling value.
186 //! If S is negative the radius stay positive but
187 //! the "XAxis" and the "YAxis" are reversed as for
189 Standard_NODISCARD gp_Circ Scaled (const gp_Pnt& P, const Standard_Real S) const;
191 void Transform (const gp_Trsf& T);
194 //! Transforms a circle with the transformation T from class Trsf.
195 Standard_NODISCARD gp_Circ Transformed (const gp_Trsf& T) const;
197 void Translate (const gp_Vec& V);
200 //! Translates a circle in the direction of the vector V.
201 //! The magnitude of the translation is the vector's magnitude.
202 Standard_NODISCARD gp_Circ Translated (const gp_Vec& V) const;
204 void Translate (const gp_Pnt& P1, const gp_Pnt& P2);
207 //! Translates a circle from the point P1 to the point P2.
208 Standard_NODISCARD gp_Circ Translated (const gp_Pnt& P1, const gp_Pnt& P2) const;
224 Standard_Real radius;
230 #include <gp_Circ.lxx>
236 #endif // _gp_Circ_HeaderFile