-
Is there a "tinfouronic" way to get the two triangles sharing a given edge? Or neighbouring triangles of a given triangle? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I love your new coinage "tinfouronic"... That's the first time I've heard that one. Now I know how Guido von Rossum must have felt :-) In answer to your question, I note that the Tinfour implementation does not maintain triangle objects internally, One of my early attempts at the package (call it "tin three") did, but the overhead was too high. So triangle objects are constructed dynamically, on an as needed basis. That being said, I think your two recent questions are pointing toward some good enhancements to the API. I'll have to think a bit more about how to best implement solutions for the requirement you've identified. For now, I would suggest:
One thing you'll have to watch out for is if the vertices C in the two triangles come back as null references. This can happen when the edge e is a perimeter edge. You might find it helpful to give a scan to the wiki page on edge-based techniques at https://github.com/gwlucastrig/Tinfour/wiki/Tutorial-Using-Edge-Based-Techniques-Part-1 I am thinking that, at the very least, I need to add a constructor to SimpleTriangle |
Beta Was this translation helpful? Give feedback.
-
I've gone with building up a map of edges-->triangles during Curiously, I get ABYSMAL performance when putting (edge, triangle) pairs into the map using the IQuadEdge object itself as a key (e.g. Using the hashcode as the key ( In which case getting a triangle's neighbours now looks like this:
|
Beta Was this translation helpful? Give feedback.
I've gone with building up a map of edges-->triangles during
TriangleCollector.visitSimpleTriangles()
and then to find neighbours for a given a triangle, querying the map using the dual of each of its edges.Curiously, I get ABYSMAL performance when putting (edge, triangle) pairs into the map using the IQuadEdge object itself as a key (e.g.
map.put(t.getEdgeA(), t);
). It would seem as though the objects' hashes are colliding but I'm not sure why this is since when I print the hashcodes they seem to be unique. This may be worth an issue in itself.Using edges as keys:
Using the hashcode as the key (
map.put(t.getEdgeB().hashCode(), t);
) results in expectedput()
performance:In which case…