Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lanelet2_extension): add guard for inner product #256

Merged
merged 7 commits into from
Jan 18, 2022
Merged
Prev Previous commit
Next Next commit
ci(pre-commit): autofix
Signed-off-by: kyoichi sugahara <81.s.kyo.19@gmail.com>
  • Loading branch information
pre-commit-ci[bot] authored and kyoichi-sugahara committed Jan 17, 2022
commit f743709cfe89664523518ec4d12641da0325caf8
7 changes: 3 additions & 4 deletions map/lanelet2_extension/lib/query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ double getAngleDifference(const double angle1, const double angle2)
vec2 << std::cos(angle2), std::sin(angle2);
double inner_product = vec1.dot(vec2);
kyoichi-sugahara marked this conversation as resolved.
Show resolved Hide resolved
double diff_angle;
if (inner_product <= -1.0)
{
if (inner_product <= -1.0) {
diff_angle = M_PI;
}else if (inner_product >= 1.0){
} else if (inner_product >= 1.0) {
diff_angle = 0.0;
}else{
} else {
diff_angle = std::acos(inner_product);
}
return std::fabs(diff_angle);
Expand Down