Skip to content
Snippets Groups Projects
Commit 6e512196 authored by Timo Koch's avatar Timo Koch Committed by Kilian Weishaupt
Browse files

[distance] Precompute distance p->a

parent 8bb64a6f
No related branches found
No related tags found
1 merge request!2723[distance] Precompute distance p->a
Pipeline #6229 waiting for manual action
...@@ -84,10 +84,11 @@ inline typename Point::value_type ...@@ -84,10 +84,11 @@ inline typename Point::value_type
distancePointSegment(const Point& p, const Point& a, const Point& b) distancePointSegment(const Point& p, const Point& a, const Point& b)
{ {
const auto ab = b - a; const auto ab = b - a;
auto t = (p - a)*ab; const auto ap = p - a;
const auto t = ap*ab;
if (t <= 0.0) if (t <= 0.0)
return (a - p).two_norm(); return ap.two_norm();
const auto lengthSq = ab.two_norm2(); const auto lengthSq = ab.two_norm2();
if (t >= lengthSq) if (t >= lengthSq)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment