From ad0e6e06addcf9a01316a6e28fe23de288ff64a0 Mon Sep 17 00:00:00 2001 From: Ian C Date: Mon, 10 Oct 2005 00:19:00 +0000 Subject: Added DoRotate() --- algorithm.mod/algorithm.bmx | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/algorithm.mod/algorithm.bmx b/algorithm.mod/algorithm.bmx index 1cac89f..378edab 100644 --- a/algorithm.mod/algorithm.bmx +++ b/algorithm.mod/algorithm.bmx @@ -73,6 +73,23 @@ Type TAlgoPoint3D End Type +Rem +bbdoc: Rotates a point. +returns: The rotated point. +about: @x, @y are rotated around 0,0 by @angle, which is the value in degrees multiplied by ten. +about: To speed things up a simple 3600 element lookup table is used, so @angle must be 0 to 3599 inclusive, or a runtime error will result. +EndRem +Function DoRotate:TAlgoPoint(x:Int, y:Int, angle:Int) + AlgoStatic.Init() + + Local dx:Double=x + Local dy:Double=y + Local dco:Double=AlgoStatic.co[angle] + Local dsi:Double=algoStatic.si[angle] + + Return TAlgoPoint.Create(dco*dx+(-dsi)*dy,dsi*dx+dco*dy) +End Function + Rem bbdoc: Implements a Bresenham style line. returns: A list of points making up the line. @@ -162,7 +179,7 @@ Function DoCircle:TAlgoPoint[](x:Int, y:Int, r:Int) AlgoStatic.Init() For f=0 To 359 - p[f]=TAlgoPoint.Create(x+r*AlgoStatic.si[f],y+r*AlgoStatic.co[f]) + p[f]=TAlgoPoint.Create(x+r*AlgoStatic.si[f*10],y+r*AlgoStatic.co[f*10]) Next Return p @@ -226,10 +243,10 @@ Type AlgoStatic Function Init() If Not done - si=New Double[360] - co=New Double[360] + si=New Double[3600] + co=New Double[3600] - For Local f:Int=0 To 359 + For Local f:Int=0 To 3599 si[f]=Sin(f) co[f]=Cos(f) Next -- cgit v1.2.3