summaryrefslogtreecommitdiff
path: root/algorithm.mod/algorithm.bmx
diff options
context:
space:
mode:
Diffstat (limited to 'algorithm.mod/algorithm.bmx')
-rw-r--r--algorithm.mod/algorithm.bmx42
1 files changed, 42 insertions, 0 deletions
diff --git a/algorithm.mod/algorithm.bmx b/algorithm.mod/algorithm.bmx
index 378edab..7020c25 100644
--- a/algorithm.mod/algorithm.bmx
+++ b/algorithm.mod/algorithm.bmx
@@ -42,6 +42,33 @@ Type TAlgoPoint
End Type
Rem
+bbdoc: Used to return double points from algorithms.
+EndRem
+Type TAlgoPointD
+ Rem
+ bbdoc: The X co-ordinate of the point
+ EndRem
+ Field x:Double
+ Rem
+ bbdoc: The Y co-ordinate of the point
+ EndRem
+ Field y:Double
+
+ Rem
+ bbdoc: Create a point.
+ returns: Newly created point.
+ about: @x and @y are initialised with the passed parameters.
+ EndRem
+ Function Create:TAlgoPointD(x:Double, y:Double)
+ Local o:TAlgoPointD=New TAlgoPointD
+ o.x=x
+ o.y=y
+ Return o
+ End Function
+
+End Type
+
+Rem
bbdoc: Used to return 3D points from algorithms.
EndRem
Type TAlgoPoint3D
@@ -91,6 +118,21 @@ Function DoRotate:TAlgoPoint(x:Int, y:Int, angle:Int)
End Function
Rem
+bbdoc: Rotates a point (double version)
+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 DoRotateD:TAlgoPointD(x:Double, y:Double, angle:Int)
+ AlgoStatic.Init()
+
+ Local dco:Double=AlgoStatic.co[angle]
+ Local dsi:Double=algoStatic.si[angle]
+
+ Return TAlgoPointD.Create(dco*x+(-dsi)*y,dsi*x+dco*y)
+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.