1 #include <IntAna2d_AnaIntersection.jxx>
4 //=======================================================================
7 //=======================================================================
8 void IntAna2d_AnaIntersection::Perform(const gp_Lin2d& L,
17 Standard_Real A,B,C0, d;
18 gp_Pnt2d aP2D, aP2D1, aP2D2;
20 L.Coefficients(A,B,C0);
21 d=A*C.Location().X() + B*C.Location().Y() + C0;
23 if (Abs(d)-C.Radius()>Epsilon(C.Radius())) {
27 else { // Au moins 1 solution
30 //modified by NIZNHY-PKV Fri Jun 15 09:55:00 2007f
32 //ang = C.XAxis().Direction().Angle(L.Direction());
33 //ang = ang + M_PI / 2.0;
34 //modified by NIZNHY-PKV Fri Jun 15 09:55:29 2007t
35 if (Abs(Abs(d)-C.Radius())<=Epsilon(C.Radius())) { // Cas de tangence
37 Standard_Real u, XS, YS, ang;
40 XS=C.Location().X() - d*A;
41 YS=C.Location().Y() - d*B;
43 //modified by NIZNHY-PKV Fri Jun 15 09:55:35 2007f
44 aP2D.SetCoord(XS, YS);
45 u=ElCLib::Parameter(L, aP2D);
46 ang=ElCLib::Parameter(C, aP2D);
48 u=B*(L.Location().X()-C.Location().X()) -
49 A*(L.Location().Y()-C.Location().Y());
50 if (d<0.0) {ang=ang+M_PI;}
58 //modified by NIZNHY-PKV Fri Jun 15 09:55:41 2007t
59 lpnt[0].SetValue(XS,YS,u,ang);
61 else { // 2 points d intersection
62 Standard_Real h, XS1,YS1, XS2,YS2, ang1,ang2, u1,u2;//,cost,sint angt;
64 h=Sqrt(C.Radius()*C.Radius()-d*d);
65 //modified by NIZNHY-PKV Fri Jun 15 09:55:47 2007f
68 //modified by NIZNHY-PKV Fri Jun 15 09:55:52 2007t
69 XS1=C.Location().X() - d*A - h*B;
70 YS1=C.Location().Y() - d*B + h*A;
71 XS2=C.Location().X() - d*A + h*B;
72 YS2=C.Location().Y() - d*B - h*A;
74 //modified by NIZNHY-PKV Fri Jun 15 09:55:57 2007f
75 aP2D1.SetCoord(XS1, YS1);
76 aP2D2.SetCoord(XS2, YS2);
77 u1=ElCLib::Parameter(L, aP2D1);
78 u2=ElCLib::Parameter(L, aP2D2);
79 ang1=ElCLib::Parameter(C, aP2D1);
80 ang2=ElCLib::Parameter(C, aP2D2);
83 if (Abs(cost)<=0.707) {
88 if (cost<0) {angt=M_PI-angt;}
96 else if (ang1>=2.0*M_PI) {
102 else if (ang2>=2.0*M_PI) {
106 u1=B*(L.Location().X()-C.Location().X()) -
107 A*(L.Location().Y()-C.Location().Y()) +h;
110 //modified by NIZNHY-PKV Fri Jun 15 09:56:19 2007t
111 lpnt[0].SetValue(XS1,YS1,u1,ang1);
112 lpnt[1].SetValue(XS2,YS2,u2,ang2);