Mercurial > hg > orthanc-stone
changeset 2011:abd4ee1648de
Fix measurement of arcs
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 02 Dec 2022 18:44:11 +0100 |
parents | 25d269c7b753 |
children | 637d6373127a |
files | Applications/StoneWebViewer/NEWS OrthancStone/Sources/Scene2D/AnnotationsSceneLayer.cpp |
diffstat | 2 files changed, 25 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/Applications/StoneWebViewer/NEWS Fri Dec 02 18:06:33 2022 +0100 +++ b/Applications/StoneWebViewer/NEWS Fri Dec 02 18:44:11 2022 +0100 @@ -2,6 +2,7 @@ =============================== * Annotations are grouped into one submenu for narrow screens +* Fix measurement of arcs Version 2.4 (2022-11-02)
--- 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: