From 512895cba915f782d36a0c7de75f0dbf2a53e2c1 Mon Sep 17 00:00:00 2001 From: Ian C Date: Mon, 26 Sep 2005 23:11:31 +0000 Subject: Added DoCirlce() command --- algorithm.mod/algorithm.bmx | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) 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 -- cgit v1.2.3