summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2005-10-10 00:19:00 +0000
committerIan C <ianc@noddybox.co.uk>2005-10-10 00:19:00 +0000
commitad0e6e06addcf9a01316a6e28fe23de288ff64a0 (patch)
tree0c2c2df4605d77cd79846a09ff2acd9d51374f68
parent004201504ed5f977cf589c8f2592cc48522a11b8 (diff)
Added DoRotate()
-rw-r--r--algorithm.mod/algorithm.bmx25
1 files 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
@@ -74,6 +74,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 <u>must</u> 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.
about: @px1, @py1, @px2 and @py2 are the end points of 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