Skip to content

Commit

Permalink
[FIX] Ensure a result between 0 and 2 Pi()
Browse files Browse the repository at this point in the history
  • Loading branch information
rlagneau committed Oct 30, 2023
1 parent 2b8de5a commit 0124b27
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/core/src/image/vpImageCircle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -990,10 +990,10 @@ float vpImageCircle::computeAngularCoverageInRoI(const vpRect &roi, const float
throw(vpException(vpException::fatalError, "This case should never happen. Please contact Inria to make fix the problem"));
}

if (delta_theta < 0) { // Needed since M_PIf is used
if (delta_theta < 0 || delta_theta > 2.f * M_PIf) { // Needed since M_PIf is used
float quotient = std::floor(delta_theta / (2.f * M_PIf));
float rest = delta_theta - quotient * 2.f * M_PIf;
if (rest < roundingTolerance && delta_theta < -M_PIf) {
if (rest < roundingTolerance && (delta_theta < -M_PIf || delta_theta > M_PIf)) {
// If the angle is a negative multiple of 2.f * M_PIf we consider it to be 2.f * M_PIf
delta_theta = 2.f * M_PIf;
}
Expand Down

0 comments on commit 0124b27

Please sign in to comment.