comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » sort points clockwise or clounterclockwise
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
sort points clockwise or clounterclockwise [message #91141] Mon, 08 June 2015 13:32 Go to next message
junsix is currently offline  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 #91158 is a reply to message #91141] Tue, 09 June 2015 09:19 Go to previous messageGo to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
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.
Re: sort points clockwise or clounterclockwise [message #91162 is a reply to message #91158] Tue, 09 June 2015 13:11 Go to previous message
junsix is currently offline  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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: buggy dictionary
Next Topic: Experience with ENVIRasterSeries?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:16:46 PDT 2025

Total time taken to generate the page: 0.00471 seconds