Commit 65300260 authored by Kilian Weishaupt's avatar Kilian Weishaupt
Browse files

Merge branch 'feature/distance-small-optimization' into 'master'

[distance] Precompute distance p->a

See merge request !2723
parents 8bb64a6f 6e512196
Pipeline #6242 passed with stages
in 0 seconds
......@@ -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)
......
Markdown is supported
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