Example code for a simple scenario, input List of Points --> output List of Triangles (List of 3 point array)? #95
-
Hi, I have only a general view about this library so before going deep I would like to know if it is possible to just use the core implementation in order to simply triangulate path2D polygons (or Lists of points) and get a list of the triangles, much like those libs do: Paths or List of points as input, list of triangles (3 point Lists) as output, those can then be converted to paths again and used as Graphics2D objects. The use case is art projects, not geographic information systems, so objectives are different, the coordinate precision remains critical though, as "double". Can we also tweak the result by using other data as "constrains" additional "list of points" or polygons? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 13 replies
-
If you have a Path2D object, extracting the points is a separate task. But here's an example of how it would work if you had the points to start with. There is more explanation on the Tinfour wiki article Three Easy Iterators
|
Beta Was this translation helpful? Give feedback.
-
A Delaunay triangulation always creates a convex enclosing polygon. So if your art object is non-convex, the code example will produce some triangles that are exterior to the art object. If this is a problem, you will have to define constraint objects, which is a somewhat more complicated problem. To learn more about how that part of the Tinfour API works, see: Using Polygon Based Constraints If you need help with that, I can probably lend some assistance. |
Beta Was this translation helpful? Give feedback.
-
Thank you!! very usefull reply, I have used the library with success in thousands of polygons. This example was very informative in order to quickly see the sequence of functions. |
Beta Was this translation helpful? Give feedback.
-
The geometry from the original path may be used provided it is not self
intersecting. Also, it must be oriented counterclockwise. The Java Path2D class can
contain a few objects that are not supported such as curved arcs.
You can use some of the techniques in the wiki article to know if a
triangle is inside your polygon or outside
…On Mon, Feb 6, 2023, 3:04 PM istinnstudio ***@***.***> wrote:
Thank you!! very usefull reply, I have used the library with success in
thousands of polygons. This example was very informative in order to
quickly see the sequence of functions.
And yes, the case with some non-convex polygons is present, the external
triangles effect is nice and surely usable, but I will try to find the way
not to create them in those spaces. I will see if I can find the way in ... Polygon
Based Constraints
<https://github.com/gwlucastrig/Tinfour/wiki/Tutorial-Using-Polygon-Based-Constraints>
Can I use the original path in order to create a Constraint for those
cases?
—
Reply to this email directly, view it on GitHub
<#95 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEWJDYK46C5EJRYYY7OOVOLWWFKMJANCNFSM6AAAAAAUSEB4PY>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Thanks for the support, it seems that for now I cannot find a way to remove those exterior triangles. But, if there would be an example based on the basic code above (with convex and non convex source) that would be great. As a final thought, as far as I can see, there could be a method that returns boolean and if called can "flag/mark" those triangles at the very begining of the tin creation, so all of them can be selected and used/removed afterwards without further conversions or "contains" calculations. Just thinking, not sure if it is a good idea or have application in other cases. |
Beta Was this translation helpful? Give feedback.
If you have a Path2D object, extracting the points is a separate task. But here's an example of how it would work if you had the points to start with.
There is more explanation on the Tinfour wiki article Three Easy Iterators