# area # MODE V = [2]REAL; [] V vt = ((-1, -1), (1, -1), (1, 1.2), (-1, 1), (-2, 0.3)); PROC dp = (V a, V b)REAL: (REAL ss := 0; FOR j TO UPB a DO ss +:= a[j]*b[j] OD; ss); PROC leng = (V v)REAL: sqrt(dp(v, v)); OP - = (V a, V b)V: (V c; FOR j TO UPB a DO c[j] := a[j] - b[j] OD; c); OP * = (REAL b, V a)V: (V c; FOR j TO UPB a DO c[j] := a[j]*b OD; c); (PROC ie = (INT i, j)REAL: (PROC ise = (INT i, j)REAL: (V tt = (vt[j] - vt[i]); V vn = (1.0/leng(tt))*tt; V vp = (vn[2], -vn[1]); dp(vt[i], vn)*dp(vt[i], vp)); ise(i, j)-ise(j, i)); # Mysterious formula: # (REAL tv := ie(UPB vt, 1); FOR j TO UPB vt - 1 DO tv +:= ie(j, j+1) OD; print(tv/2.0))); # Conventional formula: # (PROC ae = (V a, b)REAL: (a[2]+b[2])*(a[1]-b[1])/2.0; REAL ss := ae(vt[UPB vt], vt[1]); FOR j TO UPB vt - 1 DO ss+:= ae(vt[j], vt[j+1]) OD; print (ss))