@@ -150,7 +150,7 @@ QWidget *)
150
150
151
151
152
152
153
- centerLine.setLength ( centerLine.length () - myEndItem->getRadius ());
153
+ // centerLine.setLength ( centerLine.length () - myEndItem->getRadius());
154
154
155
155
QPointF endPoint = centerLine.p2 ();
156
156
QPointF startPoint = centerLine.p1 ();
@@ -295,7 +295,6 @@ QPointF Arrow::getEndItemPos() const
295
295
{
296
296
// QRectF rect = QRectF(endItem()->elipseBoundingRect().topLeft(), endItem()->pos());
297
297
return EllipseLineIntersection (endItem ()->sceneBoundingRect (), startItem ()->sceneBoundingRect ().center (), endItem ()->sceneBoundingRect ().center ());
298
-
299
298
}
300
299
}
301
300
@@ -558,18 +557,18 @@ t=-------------------
558
557
559
558
*/
560
559
561
- qreal a = elipse.width ();
562
- qreal b = elipse.height ();
560
+ qreal a = elipse.width ()/ 2.0 ;
561
+ qreal b = elipse.height ()/ 2.0 ;
563
562
qreal m = elipse.center ().x ();
564
563
qreal n = elipse.center ().y ();
565
564
qreal x1 = p1.x ();
566
565
qreal y1 = p1.y ();
567
566
qreal x2 = p2.x ();
568
567
qreal y2 = p2.y ();
569
568
570
- qreal A = b*b*(x2-x1)*(x2-x1) + a*a*(y2-y1)*(y2-y1) ;
571
- qreal B = + 2 *b*b*((x2-x1)*x1-(x2-x1) *m) + 2 *a*a*((y2-y1)*y1 - (y2-y1)*n) ;
572
- qreal C = ( x1*x1-2 *x1*m+m*m)*b*b + (y2*y2- 2 *y1*n+n*n)*a*a - a*a*b*b;
569
+ qreal A = ( x2 - x1 ) * ( x2 - x1 ) * b*b + ( y2 - y1 ) * ( y2 - y1 ) * a*a ;
570
+ qreal B = ( 2 *x1 * ( x2 - x1 ) - 2 * ( x2 - x1 ) *m) * b*b + ( 2 * y1 * ( y2 - y1 ) - 2 * (y2-y1) * n ) * a*a ;
571
+ qreal C = b*b * ( x1*x1 + m*m -2 *x1*m ) + a*a * (y1*y1 + n*n - 2 *y1*n) - a*a*b*b;
573
572
qreal D = B*B - 4 *A*C;
574
573
575
574
if (D < 0 )
@@ -578,23 +577,37 @@ t=-------------------
578
577
exit (-1 );
579
578
}
580
579
581
- qreal t1 = (-B + qSqrt (D))/2 *A;
580
+ qreal t1 = (-B + qSqrt (D))/( 2 *A) ;
582
581
QPoint intersect1 = QPoint (x1+(x2-x1)*t1,y1+(y2-y1)*t1);
583
- qreal t2 = (-B - qSqrt (D))/2 *A;
582
+ qreal t2 = (-B - qSqrt (D))/( 2 *A) ;
584
583
QPoint intersect2 = QPoint (x1+(x2-x1)*t2,y1+(y2-y1)*t2);
585
-
584
+ qDebug () <<" p1: " << p1;
585
+ qDebug () <<" p2: " << p2;
586
+ qDebug () << " Intersect: " <<intersect1;
586
587
if ((t1 >=0 && t1 <= 1 ) || (t2 >= 0 && t2 <= 1 ) )
587
588
{
588
589
if ((t1 >=0 && t1 <= 1 ) && (t2 >= 0 && t2 <= 1 ))
589
590
return (t1 < t2) ? intersect1 : intersect2;
590
591
else if (t1 >=0 && t1 <= 1 )
592
+ {
593
+ qDebug () <<" t1: " << t1;
594
+ qDebug () <<" t2: " << t2;
595
+ qDebug () << " Intersect: " <<intersect1;
591
596
return intersect1;
597
+ }
592
598
else
599
+ {
600
+ qDebug () <<" t1: " << t1;
601
+ qDebug () <<" t2: " << t2;
602
+ qDebug () <<" Intersect: " << intersect2;
593
603
return intersect2;
604
+ }
605
+
594
606
}
595
607
else
596
608
{
597
609
qDebug () << " Fatal eroor: No intersect, returning point [0,0]" ;
610
+ qDebug () << " Max qreal: " << std::numeric_limits<qreal>::max ();
598
611
qDebug () << t1;
599
612
qDebug () << t2;
600
613
qDebug () << intersect1;
0 commit comments