Determining what angle an object is moving at?

BlitzMax Forums/BlitzMax Beginners Area/Determining what angle an object is moving at?

MGE(Posted 2008) [#1]
o.x = o.x + o.xdir
o.y = o.y + o.ydir

xdir, ydir could be any values, etc, etc. They might have thrust or gravity values applied to them as well.

So, what would be the easiest way to find out the angle it's moving at? I thought about keeping track of previous positions and getting the angle on old and current. But I'm thinking there's an easier way? Thanks for any help. ;)


ziggy(Posted 2008) [#2]
Angle = atan(o.ydir/o.xdir) ?


MGE(Posted 2008) [#3]
Im getting...ZZZzzzz long night. ;) Thanks Zig, it's close but since Blitzmax uses 0 for 90 degrees I have to do something to make that work. Any ideas? Thanks!


MGE(Posted 2008) [#4]
This did the trick... ;)

angle = ATan2(yspeed, xspeed)
If angle < 0
angle = angle + 360
End If