|
|
| GeoCommunity Mailing List |
| |
| Mailing List Archives |
| Subject: | GISList: Re: clockwise-anticlockwise |
| Date: |
02/01/2003 10:22:07 AM |
| From: |
Peter Shary |
|
|
----- I apologize for possible cross-posting -----
Hi all,
The topic on polygon check and its quality understanding seems to be of general value. Please delete this message if it does not fit your interests.
------ Original message ----- From : soumen roy <soumenroys@yahoo.com> Reply-To : gisindia@yahoogroups.com To : gisindia@yahoogroups.com Subject : [GIS India] Re: clockwise-anticlockwise Date : Fri, 24 Jan 2003 20:19:07 -0800 (PST)
hi all, i am facing some typical problem in acad programming. there are many polygons in an autocad drawing. i have to check all those polygons, wheather drawn in clockwise direction or anticlockwise direction. there are nearly 2500 polygons in each drawing. so it is impossible to check it manually. i have to check it through autolisp/visual lisp programming. but i am not getting any logic to check this by programming! when a logic is working fine in 1st quadrant that is not applicable in 2nd or 3rd quadrant. can anyone give me the program, algorithm or logic for this job? soumen ----- End of the original message -----
Soumen, People have provided you with some advices, but they seem to be partial cases of the general task, and will not always work (that is, they generally will not work). I believe your real task is somewhat more complex, provided that you want to CHECK polygon, not simply to determine its clockwise-anticlockwise orientation.
Tasks of general interest in this relation:
1) Points of some polygon may be MULTIPLE in your original data, forming zero-length segments. For example, I encountered situation when a triangle was composed by 17 points: these points were located at 3 positions. Your program should internally delete extra points before further polygon treatment.
2) Polygon may be incorrect, that is, it may contain SELF-INTERSECTION, for example, polygon that looks like 8. Most GISs do not perform such check by default. Your program should check this, because in an opposite case it will provide unpredictable results in polygon orientation determining. An idea to check polygon for self-intersection is to check all pairs of segments: they should not contain mutual points, except for ends of adjacent segments. Note 1: self-intersection is often formed by a very small loop which is difficult to find manually and to visualise. Note 2: there is slightly different understanding of what is self-intersection in different GISs, see for example "durty" polygon description in ESRI's White Paper on shapefile description.
3) For a polygon with no self-intersection, your decision on its ORIENTATION (clockwise- anticlockwise) may be based on the following idea. When you pass the polygon from first point to the last point and sum angles between adjacent segments (let these angles be positive when you turn from given point clockwise, and negative in an opposite case), this sum will be (N-2)*PI for clockwise polygon, and (2-N)*PI for counterclockwise one, where N is number of points, PI=3.14... Note that this theory is not applicable to polygons that look like 8.
I have implemented these ideas in my Analytical GIS Eco (see URL http://members.fortunecity.com/eco4/giseco.html ) to automatically check hundreds of thousands of polygons 'on fly'.
Good luck, Peter ************************ Peter A. Shary, scientific researcher and GIS developer Institute of physical, chemical and biological problems of soil science of the Russian Academy of Sciences 142290 Poushchino Moscow region Russian Federation Phone: +7 (0967) 733604 Fax: +7 (0967) 790595 ************************
_________________________________________________________________ Help STOP SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail
To unsubscribe, write to gislist-unsubscribe@geocomm.com ________________________________________________________________________ GeoCommunity GeoBids - less than $1 per day! Get Access to the latest GIS & Geospatial Industry RFPs and bids http://www.geobids.com
Setup a GeoCommunity Account and have access to the GISDataDepot DRG & DOQQ Catalog http://www.geocomm.com/login.php
|
|

Sponsored by:

For information regarding advertising rates Click Here!
|