(49g 50g) Shoelace algorithm
|
08-25-2018, 01:51 AM
Post: #11
|
|||
|
|||
RE: ( HP49/50) Shoelace algorithm
(08-24-2018 02:08 PM)John Keith Wrote: If you have any suggestions for improving the rest of my area-and-centroid program I'm all ears. I used these formulas found in Centroid: \(C_{\mathrm {x} }={\frac {1}{6A}}\sum _{i=0}^{n-1}(x_{i}+x_{i+1})(x_{i}\ y_{i+1}-x_{i+1}\ y_{i})\) \(C_{\mathrm {y} }={\frac {1}{6A}}\sum _{i=0}^{n-1}(y_{i}+y_{i+1})(x_{i}\ y_{i+1}-x_{i+1}\ y_{i})\) where \(x_{n}=x_{0}\) and \(y_{n}=y_{0}\). (xs ys -- x y area) Code: « DUP TAIL OVER HEAD + ROT Example For the cat from this video: xs: { 4 0 -2 -6 -1 5 } ys: { 4 1 5 0 -4 -2 } The result is: 3: -.169696969697 2: .030303030303 1: 55 Cheers Thomas |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 6 Guest(s)