Reputation: 347
I have an algorithm which generates from three to six points of intersection between a plane and the edges of a cube which contains that plane. For drawing the plane (which gets drawn a polygon) OpenGL needs the vertex to be ordered as in the following picture:
If the vertex are unordered, this result may be drawn:
Edit: I found this question but I don't know how to code it in Python and that's not exactly what I need
Upvotes: 0
Views: 113
Reputation: 80197
If points were built as intersections between a plane and the edges of a cube, then they form convex polygon.
To properly order vertices of this polygon, make projection onto some plane - or onto section plane, or onto one of OXY, OXZ, OYZ planes - just choose one not normal to section plane and make corresponding component zero.
Then choose the leftmost point in that plane as base and sort other points by polar angle relative to base.
Upvotes: 1