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

Home » Public Forums » archive » Understanding IDLanROI
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Understanding IDLanROI [message #73195 is a reply to message #73156] Wed, 27 October 2010 08:44 Go to previous messageGo to previous message
guillermo.castilla.ca is currently offline  guillermo.castilla.ca
Messages: 27
Registered: September 2008
Junior Member
On Oct 25, 1:17 pm, Matt <sav...@nsidc.org> wrote:
>  Is this the preferred method to determine the vertex's
> direction?  internal vs external?

The below function will tell you whether a ring (i.e., a closed chain
of vertices defined by their x y coordinates) is a hole (i.e., is
ordered counterclockwise). It is based on the same principle than
Kelly's trick, but it uses only the first 3 vertices of the ring
(which form a triangle from which area can be computed), and therefore
it should be a little more efficient than the other method.

;+
; :Description: Determines whether a list of vertices forming a ring
is a hole
; (i.e., is ordered counterclockwise) or not (and then is clockwise)
;
; :Params:
; xy : in, required, type="dblarr(2\, nVertices)"
;
; :Returns: 1, if the ring is a hole; 0, otherwise
; :Categories: IDLffShape
;-
FUNCTION ishole, xy

dims = SIZE(xy, /DIMENSIONS)
IF dims[0] NE 2 THEN MESSAGE, 'The xy array must have two columns'
IF dims[1] LE 2 THEN MESSAGE, 'xy must contain at least three
vertices'

answer = (xy[0,2] - xy[0,0]) * (xy[1,1] - xy[1,0]) - $
(xy[0,1] - xy[0,0]) * (xy[1,2] - xy[1,0]) LT 0 ? 1 : 0

RETURN, answer

END

Cheers

Guillermo
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Still missing features in IDL 8
Next Topic: Subtracting arrays of same dimension, different size - interpolating one to fit the other

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

Current Time: Fri Oct 10 04:16:24 PDT 2025

Total time taken to generate the page: 1.04031 seconds