[openfirmware] r1508 - forth/lib
svn at openfirmware.info
svn at openfirmware.info
Wed Nov 25 22:28:26 CET 2009
Author: wmb
Date: 2009-11-25 22:28:25 +0100 (Wed, 25 Nov 2009)
New Revision: 1508
Added:
forth/lib/circle.fth
Log:
Checked in a rudimentary implementation of the midpoint circle algorithm.
Added: forth/lib/circle.fth
===================================================================
--- forth/lib/circle.fth (rev 0)
+++ forth/lib/circle.fth 2009-11-25 21:28:25 UTC (rev 1508)
@@ -0,0 +1,20 @@
+\ Midpoint circle algorithm - see http://en.wikipedia.org/wiki/Midpoint_circle_algorithm
+decimal
+
+d# 12 constant radius
+
+radius value y
+0 value x
+3 radius 2* - value err
+
+: step ( -- )
+ x . y . err . cr
+ err 0< if
+ x 2* 2* 6 + err + to err
+ else
+ x y - 2* 2* d# 10 + err + to err
+ y 1- to y
+ then
+ x 1+ to x
+;
+step step step step step step step step step
More information about the openfirmware
mailing list