1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
20 #include <Standard_ConstructionError.hxx>
25 inline gp_Circ::gp_Circ () : radius(RealLast())
28 inline gp_Circ::gp_Circ (const gp_Ax2& A2,
29 const Standard_Real R) : pos(A2), radius(R)
31 Standard_ConstructionError_Raise_if (R < 0.0, "");
34 inline void gp_Circ::SetAxis (const gp_Ax1& A1)
37 inline void gp_Circ::SetLocation (const gp_Pnt& P)
38 { pos.SetLocation (P); }
40 inline void gp_Circ::SetPosition (const gp_Ax2& A2)
43 inline void gp_Circ::SetRadius (const Standard_Real R)
45 Standard_ConstructionError_Raise_if (R < 0.0, "");
49 inline Standard_Real gp_Circ::Area() const
50 { return M_PI * radius * radius; }
52 inline const gp_Ax1& gp_Circ::Axis () const
53 { return pos.Axis(); }
55 inline Standard_Real gp_Circ::Length() const
56 { return 2. * M_PI * radius; }
58 inline const gp_Pnt& gp_Circ::Location () const
59 { return pos.Location(); }
61 inline const gp_Ax2& gp_Circ::Position() const
64 inline Standard_Real gp_Circ::Radius() const
67 inline gp_Ax1 gp_Circ::XAxis () const
68 {return gp_Ax1(pos.Location(), pos.XDirection());}
70 inline gp_Ax1 gp_Circ::YAxis () const
71 {return gp_Ax1(pos.Location(), pos.YDirection());}
73 inline Standard_Real gp_Circ::Distance (const gp_Pnt& P) const
74 { return sqrt(SquareDistance(P)); }
76 inline Standard_Real gp_Circ::SquareDistance (const gp_Pnt& P) const
78 gp_Vec V(Location(),P);
79 Standard_Real x = V.Dot(pos.XDirection());
80 Standard_Real y = V.Dot(pos.YDirection());
81 Standard_Real z = V.Dot(pos.Direction ());
82 Standard_Real t = sqrt( x*x + y*y) - radius;
86 inline Standard_Boolean gp_Circ::Contains
88 const Standard_Real LinearTolerance) const
89 { return Distance(P) <= LinearTolerance; }
91 inline void gp_Circ::Rotate (const gp_Ax1& A1,
92 const Standard_Real Ang)
93 { pos.Rotate(A1, Ang); }
95 inline gp_Circ gp_Circ::Rotated (const gp_Ax1& A1,
96 const Standard_Real Ang) const
99 C.pos.Rotate(A1, Ang);
103 inline void gp_Circ::Scale (const gp_Pnt& P,
104 const Standard_Real S)
107 if (radius < 0) radius = - radius;
111 inline gp_Circ gp_Circ::Scaled (const gp_Pnt& P,
112 const Standard_Real S) const
116 if (C.radius < 0) C.radius = - C.radius;
121 inline void gp_Circ::Transform (const gp_Trsf& T)
123 radius *= T.ScaleFactor();
124 if (radius < 0) radius = - radius;
128 inline gp_Circ gp_Circ::Transformed (const gp_Trsf& T) const
131 C.radius *= T.ScaleFactor();
132 if (C.radius < 0) C.radius = - C.radius;
137 inline void gp_Circ::Translate (const gp_Vec& V)
138 { pos.Translate(V); }
140 inline gp_Circ gp_Circ::Translated (const gp_Vec& V) const
147 inline void gp_Circ::Translate (const gp_Pnt& P1,
149 {pos.Translate(P1,P2);}
151 inline gp_Circ gp_Circ::Translated (const gp_Pnt& P1,
152 const gp_Pnt& P2) const
155 C.pos.Translate(P1, P2);