From e330b273da5099a7e5e564af90b319bad7e9f8f7 Mon Sep 17 00:00:00 2001 From: Ian C Date: Fri, 21 Oct 2005 02:16:12 +0000 Subject: Added double based rotation --- algorithm.mod/algorithm.bmx | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) 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 @@ -41,6 +41,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 @@ -90,6 +117,21 @@ Function DoRotate:TAlgoPoint(x:Int, y:Int, angle:Int) Return TAlgoPoint.Create(dco*dx+(-dsi)*dy,dsi*dx+dco*dy) 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 must 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. -- cgit v1.2.3