davids

11-28-2014, 07:51 AM

Hi,

I am writing a rocket simulator and I am moving the rocket along a trajectory.

I would like the rocket to point in the direction of the tangent to the trajectory.

The trajectory happens to be such that Y(t) is a parabola and X(t), Z(t) are linear, but I would like this to work for any trajectory in 3D space.

I tried using the glRotate function with angles I calculated from the slopes of x(t), y(t), z(t).

For instance, the slope of Y(X) can be calculated using the arctan of dy/dt divided by dx/dt.

This worked for some trajectories but not for all.

I have seen a few solutions that seem to involve a lot of calculations, but intuitively I assume that there must be a simple solution I am missing.

For instance, as I know where the rocket is at T and at T + dT, can I not just rotate the rocket so that it points from:

{x(t), y(t), z(t)} to {x(t+dt), y(t+dt), z(t+dt)} ?

Thanks for any tips on how to do this

David

I am writing a rocket simulator and I am moving the rocket along a trajectory.

I would like the rocket to point in the direction of the tangent to the trajectory.

The trajectory happens to be such that Y(t) is a parabola and X(t), Z(t) are linear, but I would like this to work for any trajectory in 3D space.

I tried using the glRotate function with angles I calculated from the slopes of x(t), y(t), z(t).

For instance, the slope of Y(X) can be calculated using the arctan of dy/dt divided by dx/dt.

This worked for some trajectories but not for all.

I have seen a few solutions that seem to involve a lot of calculations, but intuitively I assume that there must be a simple solution I am missing.

For instance, as I know where the rocket is at T and at T + dT, can I not just rotate the rocket so that it points from:

{x(t), y(t), z(t)} to {x(t+dt), y(t+dt), z(t+dt)} ?

Thanks for any tips on how to do this

David