How to resolve the algorithm Shoelace formula for polygonal area step by step in the EasyLang programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Shoelace formula for polygonal area step by step in the EasyLang programming language
Table of Contents
Problem Statement
Given the n + 1 vertices x[0], y[0] .. x[N], y[N] of a simple polygon described in a clockwise direction, then the polygon's area can be calculated by: (Where abs returns the absolute value) Write a function/method/routine to use the the Shoelace formula to calculate the area of the polygon described by the ordered points:
Show the answer here, on this page.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Shoelace formula for polygonal area step by step in the EasyLang programming language
Source code in the easylang programming language
proc shoelace . p[][] res .
sum = 0
for i = 1 to len p[][] - 1
sum += p[i][1] * p[i + 1][2]
sum -= p[i + 1][1] * p[i][2]
.
sum += p[i][1] * p[1][2]
sum -= p[1][1] * p[i][2]
res = abs sum / 2
.
data[][] = [ [ 3 4 ] [ 5 11 ] [ 12 8 ] [ 9 5 ] [ 5 6 ] ]
shoelace data[][] res
print res
You may also check:How to resolve the algorithm Conjugate transpose step by step in the Ada programming language
You may also check:How to resolve the algorithm Linear congruential generator step by step in the Nim programming language
You may also check:How to resolve the algorithm Mutex step by step in the Tcl programming language
You may also check:How to resolve the algorithm Reflection/Get source step by step in the J programming language
You may also check:How to resolve the algorithm HTTP step by step in the D programming language