Sign in to follow this  

Modelling turn around corner

This topic is 4304 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm trying to model the physics like the classic game "Biplanes", "Bips", "Dogfight" from various systems from Intellivision to the current day. Looking at the problem I think the physical model my fav implementation of that game uses is like Micromachines, but with gravity applied on the vertical. It's also similar to how a "super sheep" moves in "Worms World Party" and other worms games. I'm working from the book "Physics for Game Programmers" and although it's taught me alot I can't get my head around how to convert velocity to go around a corner, rather then lunar-lander style thrusting against yourself and travelling in the previous direction until the forces balance out and you start going in the direction you are thrusting. With any luck someone will have a clue about what I'm going on about and point me towards the right place. My new approach (which I've not finished trying yet) is to throw a perpendicular vector up (realitively speaking), translate that in to a centre of a turning circle and call that p, then use torque style rules to translate that as a movement around that circle, then translate those circular co-ordinates back to the cartesan system somehow. Any help would be appreciated. Thanks, Paul

Share this post


Link to post
Share on other sites
Let me quote a reply of mine, from a previous thread... The initial question was to how calculate length of curve and orientate an object with respect to it...

Quote:

If you have a parametric curve, like
u(t) = {x(t),y(t),z(t)}
and you know which values of the parameter correspond to the initial and final point, let them be t0 and t1, then the length between those points is:
Integral[from t0 to t1, sqrt(x2(t)+y2(t)+z2(t)), dt]

As for the curvature...
Find the first and second derivative of the curve. (Notice that if 't' represents time, these will be the vectors of velocity and acceleration of the object)
The vectors {t, n, b), where:
t(t) = u'/|u'|
n(t) = b X t
b(t) = u' X u"/|u' X u"|

are a right-handed orthogonal base of unit vectors, where t(t) is the tangent vector at the point u(t), n is the vector of curvature at the point u(t), and b(t) is the vector of torsion.

If you apply the following world matrix to the object...

[ n.x b.x t.x x(t) ]
[ n.y b.y t.y y(t) ]
[ n.z b.z t.z z(t) ]
[ 0 0 0 1 ]

the spaceship will orientate perfectly with respect to the curve at any of its points.


Although these vectors are supposed to be calculated from the formula of the curve, you can simply calculate them (approximately of course) from numerical data too.
You obviously know the object's position, u (numerical vector). If you know the vectors of acceleration and velocity of the object, simply replace them with the u" and u' and calculate the vectors t, n, b as suggested... (t,n,b -> tangent, normal, binormal)

If you use a left-handed coordinates system, simply negate b, and if you use DX transpose the aforementioned matrix.

edit: I forgot to mention, if only know the position u, the acceleration and velocity can be -obviously- computed.

Let xi be the position at frame 'i', ui the velocity and ai the acceleration...
Then: ui = (xi-xi-1)/dt
and ai = (ui-ui-1)/dt

Share this post


Link to post
Share on other sites
you are on the right track.

a force applied peripendicular to a velocity will not change the velocity (afterall, it does not do any work!), but merely change the direction of movement.

the force required to keep an object in a circular orbit is its mass * the acceleration needed to maintain said trajectory. for a circle with radius r, angular velocity w = v / r, x = [r*cos(w*t),r*sin(w*t)], its first der. is v = [-w*r*sin(w*t),w*r*cos(w*t)], sec der. a = [-w^2*r*cos(w*t),-w^2*r*sin(w*t)], with magnitude |a| = w^2*r = v^2/r, which is the acceleration required to maintain a trajectory with curvature r.

however, care should be taken when implementing this in a numerical way: you usually assume things to be constant throughout an integration timestep, which they clearly arnt. its numerically better to handle pure centripetal forces as a rotation of the velocity vector, to ensure they dont do any work.

[Edited by - Eelco on March 1, 2006 2:00:37 PM]

Share this post


Link to post
Share on other sites
thanks guys, both replies look very helpful and I will think through them both later. They look like different ways of doing the same thing?

I am using an ODE that is constructed in the earily stages of the book I mentioned, so I'm guessing I should be able to plug both approaches in to there, once I figure it out a bit more.

Is there any step by step tutorials about this exact problem anyone knows of? I'd prefer to understand *why* each approach would work. Part of the reason I'm doing this is to brush up on my math, rather then just getting the answer. Though both of you have worked through the solutions, so I might be able to fill in the blanks and draw pretty pictures myself [wink]

Share this post


Link to post
Share on other sites
Quote:
Original post by paulecoyote
I'd prefer to understand *why* each approach would work. Part of the reason I'm doing this is to brush up on my math, rather then just getting the answer. [wink]


Well, the vectors I proposed come from differential geometry; they are known as "Frenet's trihedron". They are a very powerful tool, since they allow you to "decompose" the curve in a very fundamental way.

Share this post


Link to post
Share on other sites
Quote:
Original post by someusername
Quote:
Original post by paulecoyote
I'd prefer to understand *why* each approach would work. Part of the reason I'm doing this is to brush up on my math, rather then just getting the answer. [wink]


Well, the vectors I proposed come from differential geometry; they are known as "Frenet's trihedron". They are a very powerful tool, since they allow you to "decompose" the curve in a very fundamental way.


Frenet Trihedron - that looks interesting, thanks loads!!! [grin]

Share this post


Link to post
Share on other sites

This topic is 4304 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this