Tracking an object such as a spaceship

Hello all

I am developing a spaceship simulator - very basic on a Mega2560. In fact, its not even a simulator, its part of a children's toy that has the ability to fly around space.

I want to set up a 'galaxy' as a cube Space_X, Space_Y and Space_Z and move around that cube as as a spaceship.

How the heck do you program that!

I have a joystick and throttle that provide me with pitch, roll and heading (all 0-359 degrees). The speed is derived from the throttle position.

I know how to program say a pixel moving away from a start point using sin and cos, with the distance from the centre of the calculation being the distance covered due to the speed (not sure if that made sense).

Every time my heading changes, the centre of the calculation would become the point at where the heading changed and the new direction would work from that point.

My issue is two fold. How do I program such movement on 3 axis?

Also, every time I change direction, I am recalculating my direction of travel and working away from that point where I changed. But... I have no actual reference point (X,Y,Z) of where I am in space?

I would need to always know where I was within the cube of 'space', so that I could produce waypoints to destinations.

No sure if any of this makes any sense. I would post code, but I pretty much don't have any at the moment.

Wondered if anyone knows of a similar project?

Thanks

V'ger needs more data....

what sensor(s) are you using ? is this all in software ?
does inertia have any effect ?

One way is to use the center of the space as 0,0,0
although you move from there to some other place, you are still referenceing your absolute coordinates based on 0,0,0

your new relational coordinates would not change your absolute, only plot where you are.

you should be able to have two simultaneous 2D calculations to give you location in your 3D environment.

What is it that you're flying? Virtual I guess - so some kind of screen output or so?

I guess it's possible - Elite was first written on the BBC microcomputer, and that's a complete 3D space shooter/trading game!

To move from point (X1, Y1) to point (X2, Y2) in a straight line, most people use the Bresenham line algorithm.

There are 3D versions.