-
A user writes...
|
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 10 replies
-
Some thoughts...
It's fairly possible and I'd try that first to check whether it is a problem with precision. For instance, the internal An alternative is the skeleton algorithm itself cannot handle the "very small, near zero length" geometries you are attempting to process, even at float-like precision (assuming they are valid geometries). Another alternative is that after subtraction, some polygon's widths get collapsed to zero, so a skeleton is impossible (this could make sense given offsetting seems to help a bit). Also, you shouldn't need to use clipper2 alongside PGS/JTS. Instead of using clipper2 to offset, you can use geom.buffer() (this is what And if you can create a minimal reproducible example, that would be handy -- I could poke around with things too. |
Beta Was this translation helpful? Give feedback.
-
Yes apparently it does and it is about the skeleton faces and not the source polygon. The only pattern I could recognize is that more complex polygons are more prone to artifacts. Polygons with holes are such a category. In my geometries there are always exactly same polygons that skeletonize right. That's why I initially thought that this is a rounding error.
For my experience there are 2 kind "triggers" of artifacts. One appears on skeletonized polygons without holes and usually can be fixed with small offset values. The other one is most apparent on multi-hole source polygons (so complex that can scramble the skeletonized faces). This one might has to do with the complexity of the source polygon and is not easily fixed, as a result and moves around on offset width change, and one other same initial polygon inherits the artifact!
For what is worth I have created a github repository with the experimental double precision versions of processing4 and pgs. I cannot say if is useful for you: GitHub - istinnstudio/processing4-double: This is a rough modification of processing4 core in order to support double precision coordinates
|
Beta Was this translation helpful? Give feedback.
-
As far as I can see and test, both kendzi and twak straight skeleton algorithms have issues on my polygons. I do not know exactly what causes those issues, probably some extreme precision calculations fail to deliver exact results. In fact using kendzi and if it fails then switch to twak actually give better (but still with artifacts) results than using them standalone. As an alternative, outside of PGS scope, I am thinking of trying to access CGAL straight skeleton implementation using the Java 21 Foreign Function and Memory API. Java swig bindings for CGAL does not support straight skeleton at the moment. |
Beta Was this translation helpful? Give feedback.
-
I have used this class: https://github.com/next-mad-hatter/straight-skeleton-study/blob/master/triton/src/main/java/util/CoordinatesScaler.java |
Beta Was this translation helpful? Give feedback.
-
That's good to know.
What kind of scaling factor are you using?
…________________________________
From: istinnstudio ***@***.***>
Sent: 28 March 2025 20:36
To: micycle1/PGS ***@***.***>
Cc: Michael Carleton ***@***.***>; Author ***@***.***>
Subject: Re: [micycle1/PGS] Rounding errors and side effects with straight skeleton algorithm (Discussion #133)
I have used this class: https://github.com/next-mad-hatter/straight-skeleton-study/blob/master/triton/src/main/java/util/CoordinatesScaler.java
Inside PGS code, transforming coordinates to those arithmetic formats increases the calculation precision in Twak algorithm. Then reverting back to double coordinates for rendering. This one eliminates artifacts to a minimum state, especially on "very small" polygons. It is not perfect but it is a significant improvement, artifacts now are rare and controllable. I could not do this for Kendzi, though, but now Twak is at least usable in my specific case.
—
Reply to this email directly, view it on GitHub<#133 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ACG7RKRLMU423XEOCH7NZ332WWQEZAVCNFSM6AAAAABUL5MC72VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTENRVHAYTAMQ>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Those algorithms behave unexpectedly if pushed hard. Before this "mod" there were frequent missing faces, now those are rare, but I get overlaid faces instead, most times in a symmetrical form, it is operation sensitive though (e.g. rotation, scaling). This is the code, it is AI in most parts, I paste it for reference:
|
Beta Was this translation helpful? Give feedback.
-
What's the code for collide() now?
The WIP PGS v2.1 points at a new version of campskeleton/twak jutils that has come changes I've made. I changed collide() from using a matrix solver to a direct solution (though precision more-or-less the same, but much it's much faster):
https://github.com/twak/jutils/blob/9b771cb488b29a38a82e1cea5400f3c77c1772fe/src/org/twak/utils/geom/LinearForm3D.java#L179
So I'm curious what a more robust version would look like.
…________________________________
From: istinnstudio ***@***.***>
Sent: 03 April 2025 11:41
To: micycle1/PGS ***@***.***>
Cc: Michael Carleton ***@***.***>; Author ***@***.***>
Subject: Re: [micycle1/PGS] Rounding errors and side effects with straight skeleton algorithm (Discussion #133)
I have managed to enhance precision a bit further by using a combination of an other coordinate scaler (affine) with a specific and "sensitive" small scale factor of 10 (e.g using 100 breaks some faces again) this time and an implementation of Shewchuk robust calculations for org.twak.utils.geom LinearForm3D Tuple3d collide method. I need more tests to ensure this. I still get some symmetrical overlaid faces so I guess this is a different hidden mystery in twak. But now results are pretty much consistent. I cannot consider this as a universal solution, just a reference. Those notes have been focused on my very special case and is a trial and error experimental process.
—
Reply to this email directly, view it on GitHub<#133 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ACG7RKTXC5EI4H5Z4KNFNSL2XUF5NAVCNFSM6AAAAABUL5MC72VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTENZRGIZTMOA>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I wonder if I can expose weights of the twak now, do you think this is possible? Is this the speed parameter in Machine class? If I change this from the default value of 10 it cannot work, in fact values other than 9.5 to 10.5 cannot work. I might look at this as it could introduce interesting results if used right. Maybe using an optional map of weights. |
Beta Was this translation helpful? Give feedback.
-
I also have a simpler version of the robust collide that seems to also work for me, here it is, might be faster :
|
Beta Was this translation helpful? Give feedback.
-
I've done some more digging... I think most of your problems are probably caused by the default tolerance value of Reducing this (even to 1e-3) fixes the problems in the demo you gave me. It make sense that increasing the scale would help, as you've experienced, since this tolerance value becomes relatively smaller compared to the coordinates -- however too small, and deformities can occur again, since events are missed. |
Beta Was this translation helpful? Give feedback.
I've done some more digging...
I think most of your problems are probably caused by the default tolerance value of
0.01
(1e-2) inHeightCollision.process()
.Reducing this (even to 1e-3) fixes the problems in the demo you gave me.
It make sense that increasing the scale would help, as you've experienced, since this tolerance value becomes relatively smaller compared to the coordinates -- however too small, and deformities can occur again, since events are missed.