You say that you need to keep track of the variables x
,y
,z
(position in space) in terms of t
(time), and you're saying about other parameters like speed, so it reminds me about parametric equations. These equations make a function of t
for x
,y
,z
, that is:
x(t) = some formula with t y(t) = some formula with t z(t) = some formula with t
which is best expressed as a vector function: the coordinates in space are pointed by a vector from the origin to the point (x,y,z)
and this vector changes as t
changes (it's a function of time): r(t).
Now you need to find these formulas connecting coordinates with t
, which might not be obvious at first. But it could be simplified by using the notion of velocity vector, v. This vector will be always tangent to the path your point r follow in space. So it's a matter of updating the position vector r(t) by adding to it the v vector to find a new position r(t+dt):
r(t+dt) = r(t) + v(t)
You only need to make the (time) step dt
sufficiently small to get more accuracy. This way allows you to track any curves in space: not only ellipses, but also lines, spirals, or anything else.
OK, but you want ellipses, right?
So now your problem moved to finding the velocity vector at each moment of time (t). But this problem has already been solved in history, by Johannes Kepler and Isaac Newton, for elliptical orbits of planets in a central gravity field. If you know a bit of physics, you can use these facts to derive proper equations for velocity from acceleration in central gravity field, which is related to distance from one of the ellipse's centers.
But if you don't want to get into details of physics, you can also use the fact that all ellipses lie in a plane, and no parts of it stick out from that plane. So you can get a formula for the ellipse in 2D planar coordinates (polar or rectangular, whichever you like more) and transform them into 3D by rotating around proper angles.
Usually this transformation can be made with matrix multiplication: you get a coordinate in 2D as a vector, extend it with zeros for other coordinates, and multiply it by a matrice which describes rotation transformation, and you'll get another vector, in a rotated coordinate system. The only thing you need is to prepare the matrix (once is enough if the plane of your ellipse doesn't change). Such transformation matrices have standard forms, which you can find over the Net (search phrase: "rotation matrix", for example). You simply insert the sines & cosines of rotation angles in the proper places and lo! a matrix could be used for transforming coordinates readily. Usually you'll find matrices for rotating around separate axes of coordinate system, X, Y, Z. But you can join these transformations together by multiplying these matrices together. You can also multiply them with the translation matrix, which can move the center of the ellipse to some other place. This is how it's usually made in 3D computer games or vector graphics/modelling.
But there's also another way of doing rotations in space, which is by use of quaternions. It needs less coordinates and factors to keep track of, but it's a bit harder to understand if you've never have any experience with them before. But it has an advantage of avoiding the problem of so called "gimbal lock", which usually makes problems with typical coordinate matrices using those three Euler angles.