Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculate area of closed loop

Status
Not open for further replies.

milkypros

Technical User
Oct 25, 2009
11
Hi
Is there any way to calculate the area of a closed loop that is created by a set of (x,y) points?
 
You mean probably the area of closed curve. But when it's not given analytically by a formula, but by a set of points, then this is not a curve, but a polygon.
There are several methods to calculate the area of polygons - google for it.
 
Place a point in the middle of the closed loop and use the sum of the halfs of the vector products (outproducts)

(This also works for volumes. In the old days they had mechanical planimeters... ...worth a google as well)
 
I wrote the program below and it works fine. But is there any way for the program to read (x,y) data from an EXCEL worksheet?

parameter(NMAX=50)
real*4 buffer(NMAX,NMAX)

s=0
npoints=13 !13 points
! init buffer x(i), y(i)
do i=1, npoints
buffer(1,1)= 3; buffer(1,2)=3
buffer(2,1)=12; buffer(2,2)=3
buffer(3,1)=12; buffer(3,2)=6
buffer(4,1)=11; buffer(4,2)=6
buffer(5,1)=11; buffer(5,2)=7
buffer(6,1)=15; buffer(6,2)=7
buffer(7,1)=15; buffer(7,2)=9
buffer(8,1)= 8; buffer(8,2)=9
buffer(9,1)= 8; buffer(9,2)=6
buffer(10,1)=4; buffer(10,2)=6
buffer(11,1)=4; buffer(11,2)=9
buffer(12,1)=3; buffer(12,2)=9
buffer(13,1)=3; buffer(13,2)=3
end do
!calculate internal surface
do i=1, npoints-1
s=s+(buffer(i,1)+buffer(i+1,1))*(buffer(i,2)-buffer(i+1,2))
end do
s=abs(s)/2
!print surface
print *,''
print *,' Surface is: ', s
print *,''
print *,''
END
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top