## Re: [stella] Angular movement

 Subject: Re: [stella] Angular movement From: Christopher Tumber Date: Wed, 14 Jan 2004 17:31:57 -0500
```>Is there a mathematical formula I can use to precisely calculate the numbers because something as simple as "45' angle up means .5/.5" isn't working.  I could manually tweak the numbers and eyeball it but I'm sure there has to be a formula.

Because you're using the wrong formula (and an incomplete one too). This is all Pythagorean theorem:

A^2=B^2+C^2

Y_____
|_|  /
|   /
B|  / A (Speed)
| /
|/
Angle

To find for Y, your values are:

The angle - 30°, 45°, whatever
A - the speed vector (the Hypotenuse)
C - Opposite side

Given the angle and the length of vector A, you can solve for any of the others:

Y=cos(angle)Speed

Similarily, for X:

X=sin(angle)Speed

For 45°, it's actually about 0.707/0.707" not .5/.5"

And that's only part way there - you still have to account for aspect ratio (4:3) and you should normalise it into byte form (preferably 2 bytes but YMMV).

Y=cos(angle)Speed*4
X=sin(angle)Speed*3

As 2 bytes values:
Y=cos(angle)Speed*256
X=sin(angle)Speed*192

And then make a table of that for however many angles you want.

Chris...

----------------------------------------------------------------------------------------------
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/

```