(49g 50g) Shoelace algorithm
|
08-26-2018, 01:47 PM
(This post was last modified: 08-27-2018 06:30 PM by John Keith.)
Post: #18
|
|||
|
|||
RE: (49g 50g) Shoelace algorithm
The only improvement I can see for Thomas's area-and-centroid program using ListExt commands is to simply replace TAIL OVER HEAD + with LRLLD so that the first two lines become
DUP LRLLD ROT DUP LRLLD. This saves about 10ms for the Cat and reduces the size from 194 to 172.5 bytes, at the cost of HP48g compatibility. Congratulations again to Thomas for a fine example of RPL programming! I can't think of a way to make a non-intersecting polygon with a large number of points other than points spread evenly around a circle, or tediously typing hundreds of points in. Based on experience I would guess that the speed ratios we have seen would hold pretty well for larger polygons. EDIT: I created a random (improper, multiply intersecting) polygon of 500 points, and a polygon made from 500 points evenly spread around a circle. For both polygons, my program from the first post takes about 42 seconds, and Thomas's program from post #11 takes about 18 seconds. The version using LRLLD is only about 100 milliseconds faster. John |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 6 Guest(s)