'***************************************************** '* This program calculates the internal surface of a * '* polygon defined by n points of coordinates: * '* x1, y1, x2, y2,...xn, yn. * '* ------------------------------------------------- * '* Ref.: "Mathematiques en Turbo-Pascal By M. Ducamp * '* and A. Reverchon (vol 2), Eyrolles, Paris, 1988" * '* [BIBLI 05]. * '* ------------------------------------------------- * '* SAMPLE RUN: * '* * '* npoints=13 * '* x1=3 y1=3 * '* x2=12 y2=3 * '* x3=12 y3=6 * '* x4=11 y4=6 * '* x5=11 y5=7 * '* x6=15 y6=7 * '* x7=15 y7=9 * '* x8=8 y8=9 * '* x9=8 y9=6 * '* x10=4 y10=6 * '* x11=4 y11=9 * '* x12=3 y12=9 * '* x13=3 y13=3 * '* * '* Surface is: 47 * '* * '* BASIC version by J-P Moreau. * '* (www.jpmoreau.fr) * '***************************************************** defint i-n NMAX=50 DIM buffer(NMAX,NMAX) s=0 npoints=13 '13 points ' init buffer x(i), y(i) for i=1 to 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 next 'calculate internal surface for i=1 to npoints-1 s=s+(buffer(i,1)+buffer(i+1,1))*(buffer(i,2)-buffer(i+1,2)) next s=abs(s)/2 'print surface cls print print " Surface is: "; s print print END ' end of file surface.bas