rotation/direction

BlitzPlus Forums/BlitzPlus Beginners Area/rotation/direction

Hi blitzcoders, can some one help me with an "rotation, direction" question.
Let's say i have created some 8, 16 or 36 or whatever rotated images(that part i allready understand). I need to know how to get the correct direction (the correct image out of, for example "36" images), when i got an angle from then mouse position or another object.
I know how to get the angle ( Atan2(y1-y2,x1-x2)) and the distance ,TotalDist# = Sqr#((XDist# * XDist#) + (YDist * YDist)). There is an example of it in the book "Learn to Program 2D games in Blitz Basic", but that function i so complex with "hundreds of variables ;)".
I only want to get an correct "direction number" out of an angle.
It should work with an Static object or an moving object, the moving part i should try to fix myself.