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 :)
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 :)