1 // Copyright (c) 1995-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 #include <Standard_ConstructionError.hxx>
20 inline gp_Circ::gp_Circ () : radius(RealLast())
23 inline gp_Circ::gp_Circ (const gp_Ax2& A2,
24 const Standard_Real R) : pos(A2), radius(R)
26 Standard_ConstructionError_Raise_if (R < 0.0, "gp_Circ() - radius should be positive number");
29 inline void gp_Circ::SetAxis (const gp_Ax1& A1)
32 inline void gp_Circ::SetLocation (const gp_Pnt& P)
33 { pos.SetLocation (P); }
35 inline void gp_Circ::SetPosition (const gp_Ax2& A2)
38 inline void gp_Circ::SetRadius (const Standard_Real R)
40 Standard_ConstructionError_Raise_if (R < 0.0, "gp_Circ::SetRadius() - radius should be positive number");
44 inline Standard_Real gp_Circ::Area() const
45 { return M_PI * radius * radius; }
47 inline const gp_Ax1& gp_Circ::Axis () const
48 { return pos.Axis(); }
50 inline Standard_Real gp_Circ::Length() const
51 { return 2. * M_PI * radius; }
53 inline const gp_Pnt& gp_Circ::Location () const
54 { return pos.Location(); }
56 inline const gp_Ax2& gp_Circ::Position() const
59 inline Standard_Real gp_Circ::Radius() const
62 inline gp_Ax1 gp_Circ::XAxis () const
63 {return gp_Ax1(pos.Location(), pos.XDirection());}
65 inline gp_Ax1 gp_Circ::YAxis () const
66 {return gp_Ax1(pos.Location(), pos.YDirection());}
68 inline Standard_Real gp_Circ::Distance (const gp_Pnt& P) const
69 { return sqrt(SquareDistance(P)); }
71 inline Standard_Real gp_Circ::SquareDistance (const gp_Pnt& P) const
73 gp_Vec V(Location(),P);
74 Standard_Real x = V.Dot(pos.XDirection());
75 Standard_Real y = V.Dot(pos.YDirection());
76 Standard_Real z = V.Dot(pos.Direction ());
77 Standard_Real t = sqrt( x*x + y*y) - radius;
81 inline Standard_Boolean gp_Circ::Contains
83 const Standard_Real LinearTolerance) const
84 { return Distance(P) <= LinearTolerance; }
86 inline void gp_Circ::Rotate (const gp_Ax1& A1,
87 const Standard_Real Ang)
88 { pos.Rotate(A1, Ang); }
90 inline gp_Circ gp_Circ::Rotated (const gp_Ax1& A1,
91 const Standard_Real Ang) const
94 C.pos.Rotate(A1, Ang);
98 inline void gp_Circ::Scale (const gp_Pnt& P,
99 const Standard_Real S)
102 if (radius < 0) radius = - radius;
106 inline gp_Circ gp_Circ::Scaled (const gp_Pnt& P,
107 const Standard_Real S) const
111 if (C.radius < 0) C.radius = - C.radius;
116 inline void gp_Circ::Transform (const gp_Trsf& T)
118 radius *= T.ScaleFactor();
119 if (radius < 0) radius = - radius;
123 inline gp_Circ gp_Circ::Transformed (const gp_Trsf& T) const
126 C.radius *= T.ScaleFactor();
127 if (C.radius < 0) C.radius = - C.radius;
132 inline void gp_Circ::Translate (const gp_Vec& V)
133 { pos.Translate(V); }
135 inline gp_Circ gp_Circ::Translated (const gp_Vec& V) const
142 inline void gp_Circ::Translate (const gp_Pnt& P1,
144 {pos.Translate(P1,P2);}
146 inline gp_Circ gp_Circ::Translated (const gp_Pnt& P1,
147 const gp_Pnt& P2) const
150 C.pos.Translate(P1, P2);