update util

This commit is contained in:
Patrick Brosi 2019-09-06 15:19:11 +02:00
parent 06aefa538a
commit a5931eb9ec
2 changed files with 10 additions and 2 deletions

View file

@ -1277,7 +1277,7 @@ inline size_t convexHullImpl(const MultiPoint<T>& a, size_t p1, size_t p2,
for (const auto& p : a) { for (const auto& p : a) {
double tmpDist = distToSegment((*h)[p1], (*h)[p2], p); double tmpDist = distToSegment((*h)[p1], (*h)[p2], p);
double cp = crossProd(p, LineSegment<T>((*h)[p1], (*h)[p2])); double cp = crossProd(p, LineSegment<T>((*h)[p1], (*h)[p2]));
if ((cp > 0) && tmpDist > maxDist) { if ((cp > 0 + EPSILON) && tmpDist > maxDist) {
pa = p; pa = p;
found = true; found = true;
maxDist = tmpDist; maxDist = tmpDist;

View file

@ -499,17 +499,23 @@ SharedSegments<T> PolyLine<T>::getSharedSegments(const PolyLine<T>& pl,
double totalDist = dist(s, e); double totalDist = dist(s, e);
while (curSegDist <= totalDist) { while (curSegDist <= totalDist) {
const Point<T>& curPointer = interpolate(s, e, curSegDist); const auto& curPointer = interpolate(s, e, curSegDist);
if (pl.distTo(curPointer) <= dmax) { if (pl.distTo(curPointer) <= dmax) {
LinePoint<T> curCmpPointer = pl.projectOn(curPointer); LinePoint<T> curCmpPointer = pl.projectOn(curPointer);
LinePoint<T> curBackProjectedPointer = projectOn(curCmpPointer.p); LinePoint<T> curBackProjectedPointer = projectOn(curCmpPointer.p);
skips = 0; skips = 0;
if (in) { if (in) {
curEndCand = curBackProjectedPointer; curEndCand = curBackProjectedPointer;
curEndCandCmp = curCmpPointer; curEndCandCmp = curCmpPointer;
if (curEndCand.totalPos < curStartCand.totalPos) {
curEndCand = curStartCand;
}
single = false; single = false;
comp = fabs(curStartCand.totalPos * length - comp = fabs(curStartCand.totalPos * length -
@ -530,6 +536,7 @@ SharedSegments<T> PolyLine<T>::getSharedSegments(const PolyLine<T>& pl,
curEndCand.totalPos * length) > MIN_SEG_LENGTH && curEndCand.totalPos * length) > MIN_SEG_LENGTH &&
fabs(curStartCandCmp.totalPos * plLength - fabs(curStartCandCmp.totalPos * plLength -
curEndCandCmp.totalPos * plLength) > MIN_SEG_LENGTH)) { curEndCandCmp.totalPos * plLength) > MIN_SEG_LENGTH)) {
assert(curStartCand.totalPos < curEndCand.totalPos);
ret.segments.push_back( ret.segments.push_back(
SharedSegment<T>(std::pair<LinePoint<T>, LinePoint<T>>( SharedSegment<T>(std::pair<LinePoint<T>, LinePoint<T>>(
curStartCand, curStartCandCmp), curStartCand, curStartCandCmp),
@ -566,6 +573,7 @@ SharedSegments<T> PolyLine<T>::getSharedSegments(const PolyLine<T>& pl,
MIN_SEG_LENGTH && MIN_SEG_LENGTH &&
fabs(curStartCandCmp.totalPos * plLength - fabs(curStartCandCmp.totalPos * plLength -
curEndCandCmp.totalPos * plLength) > MIN_SEG_LENGTH)) { curEndCandCmp.totalPos * plLength) > MIN_SEG_LENGTH)) {
assert(curStartCand.totalPos < curEndCand.totalPos);
ret.segments.push_back(SharedSegment<T>( ret.segments.push_back(SharedSegment<T>(
std::pair<LinePoint<T>, LinePoint<T>>(curStartCand, curStartCandCmp), std::pair<LinePoint<T>, LinePoint<T>>(curStartCand, curStartCandCmp),
std::pair<LinePoint<T>, LinePoint<T>>(curEndCand, curEndCandCmp))); std::pair<LinePoint<T>, LinePoint<T>>(curEndCand, curEndCandCmp)));