Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JavaFX 9.0 SVGPath arc inaccuracy...

TaronMay 9 2019 — edited May 12 2019

JavaFX 9.0 SVGPath arc inaccuracy...

Hi all, I've officially become desperate enough to join a forum in hopes for some advice. I'm sure this is how most developers arrive here, haha!

We're developing a vector based graphics app using JavaFX 9.0 and making use of SVGPaths extensively. While this is quite beautiful in many ways, it fails miserable when it comes to Arcs, of all things. I've encountered a curious problem with the end of an arc being offset, if the arc length (in degree) is not on 45 degree multiples. It's perfectly precise on 0, 45, 90, 135, 180, etc....  but the end of the arc scoots forward between 0-45 with an apex at 22.5 degree and backwards between 45-90 with apex at 67.5 degree and then rinse and repeat as you go around the circle. Our numbers are correct and even using JavaFX's own Arc class works perfectly as well as my own reconstruction, using line segments. At this point I cannot imagine that we're doing anything wrong, but that there's a problem in the source code that interprets the SVGPath.

For example: " M 0.00 -299.50 A 300.0 300.0 0 0 1 277.163859753386 -114.30502970952692 "

I know, there's of course some numerical instability or floating point imprecision, but that does not explain or justify the offset this will produce. In this example the deviation between the end of the drawn arc and the location of the actual end point is at 0.38 degrees, Depending on the radius this can be virtually a world apart and is not acceptable. Computing the center and degrees to make a JavaFX Arc will reveal again, that all the numbers are correct and should have the end point of the arc where it was in order to produce the above numbers.

I currently can only even think about fixing this by simply making my own line segment array, which is not a big problem, but a considerable inconvenience, of course. Not to mention that the above truly can only be describe as "A Bug". Though, I can't fully imagine it, there may be some weird thing we'd be doing wrong. That is why I'm coming to you with all this. Most of the time I am completely sure that I'm doing something wrong, haha, but I've done this often enough that I'm virtually out of such doubts by now.

Well, any help would be appreciated! Thanks in advance!

Taron

Comments

Post Details

Added on May 9 2019
1 comment
223 views