'
'   Copyright (C) 2004, Michael Isaac.  All rights reserved.
'

'PUBLIC CONST Radian AS Float = 0.01745329252

PUBLIC SineArray AS NEW Float[]
PUBLIC CoSineArray AS NEW Float[]

PUBLIC SUB InitializeSineTable()
    DIM I AS Integer

    'We create the cosine/sine array so we dont have to call
    'a function which had to calculate a value everytime we call it.
    'These calls are made once here, and then from now we can just
    'point at the value we want.  Should be much faster this way.

    FOR I = 0 TO 359
        SineArray.Add(Sin(I * (Pi / 180)))
        CoSineArray.Add(Cos(I * (Pi / 180)))
    NEXT
END


FUNCTION GetDistance(X1 AS Float, Y1 AS Float, X2 AS Float, Y2 AS Float) AS Float
    'RETURN Sqr((X1 - X2) ^ 2 + (Y1 - Y2) ^ 2)
    RETURN Hyp(X1 - X2, Y1 - Y2)
END


' FUNCTION CosE(A AS Float) AS Float
'     DIM Angle AS Integer
' 
'     'Convert our radian angle to a degree value
'     Angle = CInt(A * 180 / Pi)
' 
'     'Ensure we're between 0 and 359
'     DO WHILE ((Angle < 0) OR (Angle > 359))
'         IF Angle > 359 THEN Angle = Angle - 360
'         IF Angle < 0 THEN Angle = Angle + 360
'     LOOP
' 
'     'Return the value
'     RETURN CoSineArray[Angle]
' END
' 
' 
' FUNCTION SinE(A AS Float) AS Float
'     DIM Angle AS Integer
' 
'     'Convert our radian angle to a degree value
'     Angle = CInt(A * (180 / Pi))
' 
'     'Ensure we're between 0 and 359
'     DO WHILE ((Angle < 0) OR (Angle > 359))
'         IF (Angle > 359) THEN Angle = Angle - 360
'         IF (Angle < 0) THEN Angle = Angle + 360
'     LOOP
' 
'     'Return the value
'     RETURN SineArray[Angle]
' END
