diff options
author | Ian C <ianc@noddybox.co.uk> | 2005-09-26 23:11:31 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2005-09-26 23:11:31 +0000 |
commit | 512895cba915f782d36a0c7de75f0dbf2a53e2c1 (patch) | |
tree | a22c55aa3956e589e7b4d61f60bd3755adc01801 /algorithm.mod | |
parent | 2ffb85bea1c792083c3f63e5c5a7ac9ff08612de (diff) |
Added DoCirlce() command
Diffstat (limited to 'algorithm.mod')
-rw-r--r-- | algorithm.mod/algorithm.bmx | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/algorithm.mod/algorithm.bmx b/algorithm.mod/algorithm.bmx index db68305..187d2bb 100644 --- a/algorithm.mod/algorithm.bmx +++ b/algorithm.mod/algorithm.bmx @@ -116,3 +116,44 @@ Function DoLine:TList(p1x:Int, p1y:Int, p2x:Int, p2y:Int) Return list End Function + + +Rem +bbdoc: Returns the points for degrees 0-359 on the described circle. +returns: A list of points making up the circle. +about: @x, @y is the centre of the circle, @r it's radius. +EndRem +Function DoCircle:TAlgoPoint[](x:Int, y:Int, r:Int) + Local p:TAlgoPoint[]=New TAlgoPoint[360] + Local f:Int + + AlgoStatic.Init() + + For f=0 To 359 + p[f]=TAlgoPoint.Create(x+r*AlgoStatic.si[f],y+r*AlgoStatic.co[f]) + Next + + Return p +End Function + +Private + +Type AlgoStatic + Global done:Int=False + Global si:Double[] + Global co:Double[] + + Function Init() + If Not done + si=New Double[360] + co=New Double[360] + + For Local f:Int=0 To 359 + si[f]=Sin(f) + co[f]=Cos(f) + Next + + done=True + EndIf + End Function +End Type
\ No newline at end of file |