## [stella] which way to turn?

 Subject: [stella] which way to turn? From: Kirk Israel Date: Thu, 21 Jul 2005 18:12:23 -0400
```I've been using Batari BASIC to fool around with "16 position rotation
and movement":
http://www.atariage.com/forums/index.php?showtopic=73144&hl=
(btw, in addition to being n00b friendly, bB is a very good
prototyping tool...actually, "BASIC gamelogic / ASM kernal" hybrids
are probably going to be 75% as powerful as pure ASM, especially since
the BASIC is precompiled, so to speak)

So I'm trying to get something a bit like combat biplanes.  And I've
been musing on this problem: how would I get, say, an onscreen heat
seeking missile to work?

Basically, it has to know if it should turn left or right to get to the target.

Now thinking in geometry, the missile is a vector...if the target is
between 0 and 180 degrees from that factor, turn left, otherwise if
its between 180 and 260 turn right.  So I could think of some
geometry, sins and cos and what not to figure it out that way, but
that's not going to be easy or fast to code.

Can anyone think of an easy(ish) way of computing this?  I guess if my
missile is in 1 of 16 rotation positions, and you could have a quick
way to determine which of the 16 angles the target is closest to, then
it's a pretty simple math problem, just calculate if left or right is
a "closer" position.

Food for thought! I wouldn't even be sure of how to do this in Java at
the moment, I should give it a good ponder. It might have something to
do with inverse tangent but its been a long time since I remembered
how to get that from x and y.
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://stella.biglist.com

```