CCL: calculating area of a ring
- From: Matthias Rarey <rarey() zbh.uni-hamburg.de>
- Subject: CCL: calculating area of a ring
- Date: Thu, 26 Jan 2006 20:11:19 +0100
Sent to CCL by: Matthias Rarey [rarey]^[zbh.uni-hamburg.de]
Assuming your polygon has n points (x[i],y[i]), 0 <= i < n, then the
following loop should do the job:
area= 0;
for(i=0; i<n; i++) area += ( x[i]*y[(i+1)mod n] - x[(i+1)mod n]*y[i] );
return (area/2);
The function works even for a concave polygon, it should be simple,
however (meaning it has no crossing edges).
--
------------------------------------------------------------------------------
Prof. Dr. Matthias Rarey Tel. : +49 40 42838 7350
Zentrum für Bioinformatik, Universität Hamburg Fax : +49 40 42838
7352
Bundesstraße 43, 20146 Hamburg; Germany eMail:
rarey[at]zbh.uni-hamburg.de
Mills, Nancy S. nmills ~ trinity.edu schrieb:
Sent to CCL by: "Mills, Nancy S." [nmills_._trinity.edu]
Is there a program that uses cartesian coordinates (effectively x,y coordinates)
to calculate the area of a flat ring? I am interested in rings that are not
necessarily perfect polygons.