What is Nostr?
Alexandre B A Villares 🐍 /
npub13qa…alcv
2024-10-01 01:57:06

Alexandre B A Villares 🐍 on Nostr: Am I the only one who thinks #Python's frozensets are amazing and a great way to deal ...

Am I the only one who thinks #Python's frozensets are amazing and a great way to deal with recognizing duplicated polygons?

If you represent a closed polygon as a sequence of vertices, you might get many different orderings of the same "ring" (clockwise, counter-clockwise, starting at a different points of the cycle) and those are for most purposes "the same polygon". It is easy to see that "visually", but how to eliminate those duplicates in code?

If you represent the vertices as a set of edges made with frozensets you get the same result for all the possible rotations/windings that are the same polygon :)

Author Public Key
npub13qa4ushxn7jwk2lwwmj4tsshq2953hrkwmmpg57875r06x3n4d3qenalcv