# calculations..

BBS: Inland Empire Archive
Date: 01-03-93 (16:59)             Number: 244
From: WES GARLAND                  Refer#: NONE
To: JOHN GALLAS                   Recvd: NO
Subj: calculations..                 Conf: (2) Quik_Bas
Hi John!

JG> I need some help with some calculations I have to do.
JG> Lets say my spaceship has coordinates of 1550 and
JG> 1438, and is facing 348 degrees (0 being straight
JG> up), and is traveling 3 units per "update".

you a two-hour reply, explaining the practical applications
of vector math.. I hope you got it....

JG> How do I calculate how much to add (or subtract) to the X and
JG> Y?  And would it still work if I wasn't using single
JG> precision (no decimals)?

First off all, in any calculation, keep the decimals until
you absolutely can't...

ANYHOW. The easiest way to do your calculation is this...

Set up a grid like this though:
^
|___
|  /|
| / |
|/@ |
<--+----------->
|
V

Your ship is at the plus. The diagonal line is R units
long, which is the amount of space covered per update. @ is
theta, the angle between the X-axis and your ship.

So, using good ol' SOHCAHTOA,

Sin @ = NewY/R
Cos @ = NewX/R

but remember, the computer uses radians for its trig
calculations (I think... I KNOW earlier MSBasics did, and I
don't imagine they've changed it...)

So, the angle theta you plug in has to be converted from
Remember, theta is the angle between the line and the x
axis.
======CONTINUTED NEXT MESSAGE====

--- Maximus 2.01wb
* Origin: Terminal Velocity Kingston *CANADA* (613)542-4613/6594, (1:249/128)

Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET