Commit 6e512196 authored by Timo Koch's avatar Timo Koch Committed by Kilian Weishaupt
Browse files

[distance] Precompute distance p->a

parent 8bb64a6f
......@@ -84,10 +84,11 @@ inline typename Point::value_type
distancePointSegment(const Point& p, const Point& a, const Point& b)
const auto ab = b - a;
auto t = (p - a)*ab;
const auto ap = p - a;
const auto t = ap*ab;
if (t <= 0.0)
return (a - p).two_norm();
return ap.two_norm();
const auto lengthSq = ab.two_norm2();
if (t >= lengthSq)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment