I'm doing a light engine (c++, using sfml), and to connect the light vertices, I thought about drawing a triangle fan. Here is a representation of a triangle fan (sfml documentation):
The points HAVE TO be "ordered" to draw the shape correctly, otherwise it would mess the shape I suppose.
I drew the desired effect in ms paint:
As you can probably see, there is a central point, a light, and other points that I want to connect together. The problem is that the points are not always ... "In a row/Ordered" ? Let's see an example and simplify this problem.
In the example above, I can't connect the points from 0 to 8 because it would mess the shape.
I would like to reorder the points so I can connect them properly, like :
Do you have any ideas ?
I thought about doing something based on the "point in polygon" algorithm, like checking if the point is "on the right/left" but it seems complicated.
I don't necessarily need code (if you have time it would be nice) but I can try to do some, I just need ideas. Thanks



