Hello,

Here's the source code for rc-simulator. It's in three files:

	RC_FLYER.C   (the most interesting parts)
	RC_FLY2.C    (mostly vector mathematics)
	RC_FLY3.C    (initialization and other boring stuff)
	RC_FLYER.H   (header file for above c-files)

And there's also a simple project file for Borland Turbo C. It's called
RC_FLYER.PRJ. That's a sorta makefile. A simple one. Very simple. Plain
and simple.

I'll now give you a briefing on the code so it'll be easier for you to
get into it. The program was written by us in three days and during that
time we tried several different ways to code positioning and orientation
of the plane so because of that the code might be a little messy. And
also, don't be alarmed if you find functions that aren't used anywhere.
We used them in some phase of the experiment and them just left them
there because we didn't want to throw away possibly useful code.

OK, down into the files we dive! I'm writing this without now seeing the
code so I hope that I remember the function names etc. correctly.

RC_FLY3.C

This file contains functions for initializing the variables used during
the flight. InitAll inits stuff that needs to be initialized only at the
start of the program. It's here, for example, where the outlook of the
airplane is defined. You can change the appearence of the airplane by
changing the values set into pAirplane. The fuselage has the three 
first points, fin has next two point, stabilizer has the next four and
wing the next four.

InitFlight initializes the variables that must be set to their default
values before every flight. This function is called whenever 'i' is 
pressed.

ShowIntroScreen just paints the intro screen. Don't change this much,
ok. Or atleast leave the Mikko's and Harri's Magnificient RC-Simulator
text. Other functions in this file I don't remember so they can't be
that important.

RC_FLY2.C 

This file is filled with vector mathematics. CalcViewVectors and
TwistPoint are used for changing 3D-points from world coordinate system
into viewers coordinate system. ProjectToPixel and ProjectToPoints is
used for projecting the 3D-point into EGA (640x350) screen. If you want
to have a different resolution, check these (Project...) functions out.

RotateVector is a good function. It rotates a vector about a given
vector the given angle. It's just so happens that we no longer need that
function. Pity.

RC_FLYER.C

This is the main file concerning rc-flying. ReadKeyboardContorls reads
what the user has pressed and set the variables according to that. If
you plan to code a joystick control, this is the place for it.

MoveAirplane is probably the most important function. This is where the
airplane is moved to it's new location and orientation based on old
speed, engine power, gravity, lift, air drag and control surfaces. The
principle is like this:

1) lift vector points up of the airplane

2) engine vector points forward of the fuselage

3) air drag vector points backward of the fuselage

4) gravity vector always points straight down (0,0,-1)

5) elevator control (fStickYPos) rotates fuselage about wing

6) aileron control (fStickXPos) rotates wing about fuselage

The new place for airplane is the sum of these vectors and the airplane
is twisted so the it always points where it heading. Now, I didn't like
this idea but Harri suggested it and I had nothing better to offer him
so we decided to have it this way. In reality the plane does not always
point where it's heading so this might cause some abnormalies in the
flying characteristics.

And finally UpdateScreen draws a new frame in the simulation. If you
want to import the simulator into some other graphics environment, this
is the place to look. We use two graphics pages so that there's no
flicker between the frames. EGA supports this and one friend of mine said
that VGA-cards also support this. I tried it with VGA mode (640x480x16) but
it didn't work so we settled for EGA graphics.

I think that's about it. Should any questions arise, please feel free to
mail us and ask. Hope you'll get something out of this. And if you do
manage to create nice new features, please have the new version of the
program available for all (and for free).

Mikko Oksalahti and Harri Rautio
