Shoelace formula for polygonal area: Difference between revisions
Content added Content deleted
m (→{{header|Phix}}: syntax coloured, made p2js compatible) |
(Shoelace formula for polygonal area in BASIC256) |
||
Line 279: | Line 279: | ||
{{out}} |
{{out}} |
||
<pre>30.000000</pre> |
<pre>30.000000</pre> |
||
=={{header|BASIC256}}== |
|||
<lang BASIC256>arraybase 1 |
|||
dim array = {{3,4}, {5,11}, {12,8}, {9,5}, {5,6}} |
|||
print "The area of the polygon = "; Shoelace(array) |
|||
end |
|||
function Shoelace(p) |
|||
sum = 0 |
|||
for i = 1 to p[?][] -1 |
|||
sum += p[i][1] * p[i +1][2] |
|||
sum -= p[i +1][1] * p[i][2] |
|||
next i |
|||
sum += p[i][1] * p[1][2] |
|||
sum -= p[1][1] * p[i][2] |
|||
return abs(sum) \ 2 |
|||
end function</lang> |
|||
=={{header|C}}== |
=={{header|C}}== |