Marco Rofei a ?crit :
>
>> draw doesn't provide such a function. As far as I can say, you have to
>> order the vertices by hand or write your own function (a convex hull
>> algorithm?)
>>
>
> What is "convex hull" algorithm?
The convex hull of a finite set of points (P_i) is the smallest convex
set containing these points. It is a convex polygon whose vertices are
some of the P_i's. The problem is to find which ones, and to order them
clockwise (or anticlockwise).
If you know in advance that all P_i's are vertices of the convex hull,
one way to find the order is this :
- take one of your points, say P_0 as reference point
- order the P_i's according to the angle between horizontal and vector
P_0P_i (that means P_i<P_j iff P_j is on the left of vector P_0P_i,
very simple equation between their coordinates). Use distance from P_0
to treat the case of equality.
In the general case you have to modify this algorithm to exclude some
"inner" points.
For example see
http://www.softsurfer.com/Archive/algorithm_0109/algorithm_0109.htm
The complexity of the algorithm is the same as complexity of sorting : n
ln(n). It is much harder in higher dimensions (useful to draw polyhedra
for instance).
HTH
Eric