## Re: [stella] Real 3D Space Calculations

 Subject: Re: [stella] Real 3D Space Calculations From: "Roger Williams" Date: Wed, 29 Aug 2001 18:41:36 -0500
Polar- (or Spherical) coordinates seem to be one of the keys to success.
```Absolutely.  In order to draw the screen, you must convert everything
in the game universe into ship-centered spherical coordinates.  This
will involve three angles, usually labelled rho, theta, and phi, as well
as a radius.  (The third angle is the object's rotation, which is
trivial in cartesian co-ords but not in polar.)  You can then translate
to ship-VIEWPOINT spherical co-ordinates by doing simple addition
to rho and theta.  You can then locate the object on the screen by
treating rho and the arctangent of rho * the radius as polar co-ords
and converting back into cartesian in the screen space.  Phi
directly tells you the object's rotation as it needs to be plotted, and
the polar radius its size.  In this co-ordinate system you can also
move and  rotate the ship very easily before converting back to
spherical.```

The more I'm reading about it, the more I think it's doable on the VCS.
```The main problem is that all the values are going to have to be 16-bit
to get the motion smooth enough, and you will need at least 4 16-bit
random multiplications to do each transform in both directions.  That
is a lot of uncertain cycle-count code.  You might be able to distribute
the math across multiple vertical blanks, though.```

```I have done and tested some 8086 routines that do fast integer trig
and polar-to-cart conversions, and I have an old BASIC program that
uses them to simulate a roulette wheel (in real time, on a 386DX20,
at 640x480).  They use MUL and 16-bit regs but illustrate the
principles; if you want I'll send them along.```

--Roger Williams

```_________________________________________________________________
```-