# Modelling turn around corner

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

## 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 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 tb(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 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 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 on other sites
Quote:
 Original post by paulecoyoteI'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 on other sites
Quote:
Quote:
 Original post by paulecoyoteI'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]

1. 1
Rutin
42
2. 2
3. 3
4. 4
5. 5

• 18
• 20
• 14
• 14
• 9
• ### Forum Statistics

• Total Topics
633370
• Total Posts
3011542
• ### Who's Online (See full list)

There are no registered users currently online

×