Skip to content

Commit

Permalink
fixing special case (was triggering assertion) refs #3861
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Mar 2, 2018
1 parent 9ba87dc commit 1be5765
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/microsim/MSLink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,17 @@ MSLink::setRequestInformation(int index, bool hasFoes, bool isCont,
// we want to make sure that both vehicles have the same distance to the crossing point and thus follow each other naturally
std::vector<double> distances = l.distances(s);
assert(distances.size() == l.size() + s.size());
for (int j = s.size() - 2; j >= 0; j--) {
int i = j + l.size();
const double segLength = s[j].distanceTo2D(s[j + 1]);
if (distances[i] > minDist) {
lbcSibling += segLength;
} else {
// assume no sharp bends and just interpolate the last segment
lbcSibling += segLength - (minDist - distances[i]) * segLength / (distances[i + 1] - distances[i]);
break;
if (distances.back() > minDist) {
for (int j = s.size() - 2; j >= 0; j--) {
int i = j + l.size();
const double segLength = s[j].distanceTo2D(s[j + 1]);
if (distances[i] > minDist) {
lbcSibling += segLength;
} else {
// assume no sharp bends and just interpolate the last segment
lbcSibling += segLength - (minDist - distances[i]) * segLength / (distances[i + 1] - distances[i]);
break;
}
}
}
assert(lbcSibling >= -NUMERICAL_EPS);
Expand Down

0 comments on commit 1be5765

Please sign in to comment.