Physics question

Ok, given position, speed, direction and rate of turning, how can I calculate the position of the object at some point in the future?

Is the rate of turning a constant (over a given time interval)? If not, it can get a little complicated.

[This message has been edited by DFrey (edited 08-14-2001).]

Also is this 2D or 3D motion? Also where is the center of the turn? If this is 3D motion, it would make things easier if you know what the turning axis is as well.

Yeah, I probably should of said that in the question. Speed & turning are constant. It’s 2d motion: ignore the y-coordinate. Turning only occurs on the XZ plane.

Ok, then its relatively simple:
Here is some sample code that does that, you can pick out the important parts.

#include <math.h>

using namespace std;

const double pi=3.14159265;

int main(int num, char *cmd[])
double x0[2],x1[2],v[2],xp[2],w;
double r[2],n[2],radius,theta0,theta1;

// try out a sample condition

double t=1; // t: time interval in seconds

w=pi; //w: turning rate in radians per second
x0[0]=x0[1]=0; //x0: initial position
// v: inital velocity

double s;
// linear motion
// circular motion
double vmag=s

cout << "Final position " << x1[0] << " " << x1[1] << endl;

return 0;

Of course you also have to add code to handle the case when vmag=0.

[This message has been edited by DFrey (edited 08-15-2001).]

Thanks! I don’t exactly understand all of it, but the results seem to make sense and movement looks smoother now

Hi !

Where can I find such code ??(book,pdf-file … ??)

mfg dominik

I do not know offhand, I cooked that code up myself on the spur of the moment (my physics degree proved helpful for once ). It has a lot of room for improvement too.

But if you are looking for general physics routines, a search engine should point the way.

Could you think of a way in 3d incorporating roll and drift? It must have something to do with spirals, but my current physics teacher couldn’t tell me how to do it. I ended up slicing it into small time periods of linear motion (actually per frame… ), but I would think that this would lead to a slightly bigger radius than the realistic movement. Thanks!

Do you know any linear algebra? You ought to be able to use a forward vector, an up vector, velocities for each, and a rotation matrix for all of this. if you use the rotation matrix and you only have 1 angular velocity then i think it will cut down on the amount of computations the CPU has to do in each frame. i can help you with this if you don’t know how to do it.

I’m actually able to do it in linear steps. Means, the camera rotates appropriately to the duration of the last frame, moves a step (one frame) and then again. That’s no problem if you mean that. I’m actually talking about a spiral-like curve. Maybe I got you wrong. Any help is welcome!