Mercurial > hg > orthanc-stone
diff OrthancStone/Sources/Scene2D/AnnotationsSceneLayer.cpp @ 2011:abd4ee1648de
Fix measurement of arcs
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 02 Dec 2022 18:44:11 +0100 |
parents | 1bb0a9716876 |
children | 07964689cb0b |
line wrap: on
line diff
--- a/OrthancStone/Sources/Scene2D/AnnotationsSceneLayer.cpp Fri Dec 02 18:06:33 2022 +0100 +++ b/OrthancStone/Sources/Scene2D/AnnotationsSceneLayer.cpp Fri Dec 02 18:44:11 2022 +0100 @@ -653,21 +653,34 @@ const double yc = middle_.GetY(); const double x2 = end_.GetX(); const double y2 = end_.GetY(); - - startAngle = atan2(y1 - yc, x1 - xc); - endAngle = atan2(y2 - yc, x2 - xc); - - fullAngle = endAngle - startAngle; - - while (fullAngle < -PI) + + double referenceAngle = atan2(y1 - yc, x1 - xc); + double secondAngle = atan2(y2 - yc, x2 - xc); + + secondAngle -= referenceAngle; + + while (secondAngle >= PI) + { + secondAngle -= 2.0 * PI; + } + + while (secondAngle <= -PI) { - fullAngle += 2.0 * PI; + secondAngle += 2.0 * PI; + } + + if (secondAngle < 0) + { + startAngle = referenceAngle + secondAngle; + endAngle = referenceAngle; } - - while (fullAngle >= PI) + else { - fullAngle -= 2.0 * PI; + startAngle = referenceAngle; + endAngle = referenceAngle + secondAngle; } + + fullAngle = endAngle - startAngle; } public: