Post Reply 
(49g 50g) Shoelace algorithm
08-24-2018, 03:56 AM
Post: #5
RE: ( HP49/50) Shoelace algorithm
Alternatively we can use

\(A=\frac{1}{2}\sum_{i=1}^{n}x_{i}(y_{i+1}-y_{i-1})\)

where \(y_{n+1}=y_{1}\) and \(y_{0}=y_{n}\).

(xs ys -- area)
Code:
« DUP TAIL OVER HEAD + SWAP
  REVLIST DUP TAIL SWAP HEAD + REVLIST
  - * ∑LIST 2 /
»

The coordinates of the polygon have to be entered as two separate lists xs and ys.
There might be better ways to rotate the elements of ys left and right.

Kind regards
Thomas
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(49g 50g) Shoelace algorithm - John Keith - 08-23-2018, 02:20 PM
RE: ( HP49/50) Shoelace algorithm - Thomas Klemm - 08-24-2018 03:56 AM



User(s) browsing this thread: 2 Guest(s)