@@ -448,12 +448,12 @@ class RegressionLine
448
448
a = +sumXY / std::sqrt (sumXX * sumXX + sumXY * sumXY);
449
449
b = -sumXX / std::sqrt (sumXX * sumXX + sumXY * sumXY);
450
450
}
451
- if (_directionInward * normal () < 0 ) {
451
+ if (dot ( _directionInward, normal () ) < 0 ) {
452
452
a = -a;
453
453
b = -b;
454
454
}
455
- c = normal () * mean; // (a*mean.x + b*mean.y);
456
- return _directionInward * normal () > 0.5 ; // angle between original and new direction is at most 60 degree
455
+ c = dot ( normal (), mean) ; // (a*mean.x + b*mean.y);
456
+ return dot ( _directionInward, normal () ) > 0.5 ; // angle between original and new direction is at most 60 degree
457
457
}
458
458
459
459
template <typename Container, typename Filter>
@@ -474,7 +474,7 @@ class RegressionLine
474
474
int length () const { return _points.size () >= 2 ? int (distance (_points.front (), _points.back ())) : 0 ; }
475
475
bool isValid () const { return !std::isnan (a); }
476
476
PointF normal () const { return isValid () ? PointF (a, b) : _directionInward; }
477
- double signedDistance (PointI p) const { return normal () * p - c; }
477
+ double signedDistance (PointI p) const { return dot ( normal (), p) - c; }
478
478
PointF project (PointI p) const { return p - signedDistance (p) * normal (); }
479
479
480
480
void reverse () { std::reverse (_points.begin (), _points.end ()); }
@@ -483,7 +483,7 @@ class RegressionLine
483
483
assert (_directionInward != PointF ());
484
484
_points.push_back (p);
485
485
if (_points.size () == 1 )
486
- c = normal () * p ;
486
+ c = dot ( normal (), p) ;
487
487
}
488
488
489
489
void pop_back () { _points.pop_back (); }
@@ -605,7 +605,7 @@ class EdgeTracer : public BitMatrixCursor<PointI>
605
605
auto old_d = d;
606
606
setDirection (p - origin);
607
607
// if the new direction is pointing "backward", i.e. angle(new, old) > 90 deg -> break
608
- if (d * old_d < 0 )
608
+ if (dot (d, old_d) < 0 )
609
609
return false ;
610
610
// make sure d stays in the same quadrant to prevent an infinite loop
611
611
if (std::abs (d.x ) == std::abs (d.y ))
@@ -651,7 +651,7 @@ class EdgeTracer : public BitMatrixCursor<PointI>
651
651
// In case the 'go outward' step in traceStep lead us astray, we might end up with a line
652
652
// that is almost perpendicular to d. Then the back-projection below can result in an
653
653
// endless loop. Break if the angle between d and line is greater than 45 deg.
654
- if (std::abs (normalized (d) * line.normal ()) > 0.7 ) // thresh is approx. sin(45 deg)
654
+ if (std::abs (dot ( normalized (d), line.normal () )) > 0.7 ) // thresh is approx. sin(45 deg)
655
655
return false ;
656
656
657
657
auto np = line.project (p);
@@ -663,7 +663,7 @@ class EdgeTracer : public BitMatrixCursor<PointI>
663
663
p = round (np);
664
664
}
665
665
else {
666
- auto stepLengthInMainDir = line.points ().empty () ? 0.0 : mainDirection (d) * (p - line.points ().back ());
666
+ auto stepLengthInMainDir = line.points ().empty () ? 0.0 : dot ( mainDirection (d), (p - line.points ().back () ));
667
667
line.add (p);
668
668
669
669
if (stepLengthInMainDir > 1 ) {
0 commit comments