1 //--------------------------------------------------------------------
3 // File Name : IGESGeom_CircularArc.cxx
5 // Author : CKY / Contract Toubro-Larsen
6 // Copyright : MATRA-DATAVISION 1993
8 //--------------------------------------------------------------------
10 #include <IGESGeom_CircularArc.ixx>
11 #include <gp_Dir2d.hxx>
12 #include <gp_GTrsf.hxx>
15 IGESGeom_CircularArc::IGESGeom_CircularArc () { }
17 void IGESGeom_CircularArc::Init
18 (const Standard_Real aZT, const gp_XY& aCenter,
19 const gp_XY& aStart, const gp_XY& anEnd)
25 InitTypeAndForm(100,0);
29 gp_Pnt2d IGESGeom_CircularArc::Center () const
31 gp_Pnt2d Center(theCenter);
35 gp_Pnt IGESGeom_CircularArc::TransformedCenter () const
37 gp_XYZ Center(theCenter.X(), theCenter.Y(), theZT);
38 if (HasTransf()) Location().Transforms(Center);
39 gp_Pnt transCenter(Center);
43 gp_Pnt2d IGESGeom_CircularArc::StartPoint () const
45 gp_Pnt2d Start(theStart);
49 gp_Pnt IGESGeom_CircularArc::TransformedStartPoint () const
51 gp_XYZ Start(theStart.X(), theStart.Y(), theZT);
52 if (HasTransf()) Location().Transforms(Start);
53 gp_Pnt transStart(Start);
57 Standard_Real IGESGeom_CircularArc::ZPlane () const
62 gp_Pnt2d IGESGeom_CircularArc::EndPoint () const
68 gp_Pnt IGESGeom_CircularArc::TransformedEndPoint () const
70 gp_XYZ End(theEnd.X(), theEnd.Y(), theZT);
71 if (HasTransf()) Location().Transforms(End);
76 Standard_Real IGESGeom_CircularArc::Radius () const
78 Standard_Real x1, y1, x2, y2;
84 Standard_Real radius = Sqrt(Square(x2 - x1) + Square(y2 - y1));
88 Standard_Real IGESGeom_CircularArc::Angle () const
90 Standard_Real x1, y1, x2, y2, xc, yc;
97 gp_Dir2d dir1(x1-xc, y1-yc); // After shifting the centre of
99 gp_Dir2d dir2(x2-xc, y2-yc); // After shifting the centre of
101 Standard_Real t = dir1.Angle(dir2);
102 return t + (t > 0 ? 0 : 2*M_PI);
105 gp_Dir IGESGeom_CircularArc::Axis () const
107 gp_Dir axis(0.0 , 0.0, 1.0);
111 gp_Dir IGESGeom_CircularArc::TransformedAxis () const
113 gp_XYZ axis(0.0 , 0.0, 1.0);
114 if (!HasTransf()) return gp_Dir(axis);
115 gp_GTrsf loc = Location();
116 loc.SetTranslationPart (gp_XYZ(0.,0.,0.));
117 loc.Transforms(axis);
121 Standard_Boolean IGESGeom_CircularArc::IsClosed () const
123 return (Abs (theStart.X() - theEnd.X()) < Precision::PConfusion() && Abs (theStart.Y() - theEnd.Y()) < Precision::PConfusion());