Post Reply 
(49g 50g) Shoelace algorithm
08-23-2018, 03:33 PM
Post: #2
RE: ( HP49/50) Shoelace algorithm
(08-23-2018 02:20 PM)John Keith Wrote:  My program differs in that it takes a list of coordinates of the form
{ X1 Y1 X2 Y2...Xn Yn }
instead of a list of two-element vectors.

Code:

\<< DUP 1. 2. SUB + 4.
  \<< NSUB 2. MOD { UNROT * UNROT * SWAP - } { DROP2 DROP2 } IFTE
  \>> DOSUBS \GSLIST ABS 2 /
\>>

Why is SWAP necessary ?
Does ABS remove the sign of sum anyway ?

Sorry if the question sound stupid, I do not know RPL.
A mini-tutorial of how above code work would be nice ...

Does "DUP 1. 2. SUB +" produce {X1 Y1 X2 Y2...Xn Yn X1 Y1} ?
Is this "flatten" list (pick 4 at a time) the reason for the 2.5X speedup ?
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 - Albert Chan - 08-23-2018 03:33 PM



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