diff options
-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 |