Hi Jacques,
The most common way is done thru dot products or (quite identical) signed
area :
Here's an mb snippet that should do the job (not for 'beignes' though ;) )
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function CheckCCW (NNodes as integer) as logical
' Returns true if Polygon Vertex orientation is Counterclockwise
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function CheckCCW (NNodes as integer) as logical
Dim DoubleSignedBaseArea as float
Dim i as integer
DoubleSignedBaseArea = 0
For i = 1 to NNodes -1
DoubleSignedBaseArea = DoubleSignedBaseArea + ((VolumeSet.VCoord(i).X *
VolumeSet.VCoord(i+1).Y )- (VolumeSet.VCoord(i+1).X *
VolumeSet.VCoord(i).Y ))
next
DoubleSignedBaseArea = DoubleSignedBaseArea + ((VolumeSet.VCoord(NNodes).X
* VolumeSet.VCoord(1).Y )- (VolumeSet.VCoord(1).X *
VolumeSet.VCoord(NNodes).Y ))
If DoubleSignedBaseArea > 0 then
CheckCCW = TRUE
Else
CheckCCW = False
End IF
End Function
Since this was a function of my old Virtual Reality generator, it delt with
volumes :), but here volume means the base polygon only (replace
volumeset.coords with your polygon coords).
PS (private joke) : am I back in the game ?
Eric Maranne
EMI Informatiques : www.geovrml.com
(33)(+) 4 42 06 22 22
Port de Bouc - France :
http://www3.calle.com/info.cgi?lat=43.4000&long=4.9833&name=Port%2dde%2dBouc
&cty=France&alt=0
43� 23' 60N 4� 58' 60E Alt: 0
> -----Message d'origine-----
> De : [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]De la part de Jacques
> Paris
> Envoy� : lundi 21 janvier 2002 22:12
> � : MIL
> Objet : MI-L MB: polygon drawing direction.
>
>
>
>
> I would like to learn about a simple way to find if a polygon was drawn
> clockwise or counter clockwise. I would rather not go through lengthy
> calculations (someone mentioned some sum of angles) but I will be thankful
> for any answer.
>
> Jacques Paris
> e-mail [EMAIL PROTECTED]
> MapBasic-MapInfo support http://www.paris-pc-gis.com
>
>
>
>
> _______________________________________________________________________
> List hosting provided by Directions Magazine | www.directionsmag.com |
> To unsubscribe, send e-mail to [EMAIL PROTECTED] and
> put "unsubscribe MapInfo-L" in the message body.
_______________________________________________________________________
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, send e-mail to [EMAIL PROTECTED] and
put "unsubscribe MapInfo-L" in the message body.