sort points clockwise or clounterclockwise [message #91141] |
Mon, 08 June 2015 13:32  |
junsix
Messages: 3 Registered: June 2015
|
Junior Member |
|
|
Hi,
I am trying to order points of closed polygon in clockwise or counterclockwise.
Here is a octagon and I tried to use Triangulate that I searched.
2 0
6 3
4 5
1 7
IDL> x=[3.,2.,2.,4.,1.,4.,1.,3.]
IDL> y=[4.,1.,4.,3.,2.,2.,3.,1.]
IDL> TRIANGULATE, X, Y, Triangles
IDL> help,triangles
TRIANGLES LONG = Array[3, 6]
IDL> print,triangles
4 1 7
4 7 6
6 7 2
2 7 5
2 5 3
2 3 0
The Triangulate returns each triangles in clockwise, while points in each triangles in counterclockwise.
But, what I need is to order points in clockwise or counterclockwise, e.g. 146203571 or 75302641, and then make polygon to calculate area and perimeter.
Thank you in advance.
Jun
|
|
|
|
Re: sort points clockwise or clounterclockwise [message #91162 is a reply to message #91158] |
Tue, 09 June 2015 13:11  |
junsix
Messages: 3 Registered: June 2015
|
Junior Member |
|
|
On Tuesday, June 9, 2015 at 11:19:54 AM UTC-5, Craig Markwardt wrote:
> On Monday, June 8, 2015 at 4:32:53 PM UTC-4, junum wrote:
>> Hi,
>>
>> I am trying to order points of closed polygon in clockwise or counterclockwise.
>> Here is a octagon and I tried to use Triangulate that I searched.
>
>
> I would never have thought to use TRIANGULATE to order items.
>
> Why not use ATAN(Y,X) which gives the angle. Your points are not centered on the origin. But that is easy enough, your circle is centered on (2.5,2.5)
>
> ANGLE = ATAN(Y-2.5,X-2.5)
>
> Now sort on ANGLE.
That is the solution.
Thank you very much for help!
Jun
|
|
|