(49g 50g) Shoelace algorithm

02282019, 02:43 PM
(This post was last modified: 08302019 10:11 PM by Albert Chan.)
Post: #21




RE: (49g 50g) Shoelace algorithm
(08252018 02:02 PM)Albert Chan Wrote: Let xr = rotatedleft x, yr = rotatedleft y ... Just noticed this rearranged shoelace area formula can proof itself easily: A = ½ sum((xr + x)(yr  y)) = ½ sum((yr + y)(xr  x)) A = \( \large \left \left[\sum_{i=1}^{n1}\frac{(y_{i+1}+y_{i})}{2}(x_{i+1}x_{i}) \right]  \frac{(y_{n}+y_{1})}{2} ( x_{n}x_{1}) \right \) First term is summing all the little trapezoid areas. Last term is area of the base. Update: polygon area and perimeter implemented in Mathematica area[v_] := Apply[area, Transpose[v]]; (* v = list of vertices *) area[x_, y_] := Abs[Dot[RotateLeft[x]+x, RotateLeft[y]y]] / 2 perimeter[x_,y_] := Plus @@ Abs[MapThread[Complex, {RotateLeft[x]x, RotateLeft[y]y}]] 

07132019, 01:20 PM
Post: #22




RE: (49g 50g) Shoelace algorithm
Another interesting (and short!) version by user telemachos in this thread.


08242019, 01:19 PM
Post: #23




RE: (49g 50g) Shoelace algorithm
At Albert Chan's request, I am posting an HP48G / HP 50 program for the perimeter of a polygon. Stack diagram is the same as for Thomas's programs for polygon area and centroid:
xs ys > p Code:


« Next Oldest  Next Newest »

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