Sign in to follow this  
razorjack

Questions about movement trajectory

Recommended Posts

razorjack    143
Maybe my questions would belong also to AI programming.... I want to implement spline trajectories for the AI of space vessels. Because I'm going to use newton physics I need to implement more a nontrivial algorithm to navigate a vessel through a given path. What I know is that a ship is allowed to fly at a maximal speed without going into problem to break out from its trajectory line. And because of inertia a ship should slow down at curves. And now my first question: Having a mass parameter for a ship. How can I determine the maximal allowed velocity at every position on the trajectory? And a second problem of minimization: An improvement of such navigation algorithm could be a tunnel instead of a trajectory line where a vessel has a possibility to choose any path inside the tunnel. How can I choose the fastest path? Answers of all kind would be welcome, also pure mathematical theories :) Thank you in advance for any answer

Share this post


Link to post
Share on other sites
h4tt3n    1974
@ razorjack

I might be able to help you a little. Some time ago I wrote a function that predicted the (eliptical) trajectory of a body from its present state vectors (fancy word for the position and velocity vectors). I've also made a few simple game AI's to keep sattellites in a circular orbit of predefined radius.

A few Q's to get things straight:

Is this in 2d or 3d?

Are you looking for a way to always keep a spaceship on a predefined "track" of any shape, alhough this track is not necessarily a cone section?

OR...

Are you just looking for a way to make the ship's trajectory intersect a predefined destination point?

Cheers, Michael

Share this post


Link to post
Share on other sites
razorjack    143
The Coordinatespace should be in 3D.
I'm using each arbitrary spline as a track shape. And I regard only open shapes having a start and destination point.

The first question is related to a problem where the ship should follow exactly a predefined trajectory.

The second question is related to a another problem. In that case I don't require an "exact" trajectory. Instead of this the ship should stay inside a tunnel surrounding a predefined track. Or better, it should find the fastest track inside this tunnel to reach his destination. The improvement towards the first problem is that the ship is allowed to rise his velocity a little bit more.

Share this post


Link to post
Share on other sites
daftasbrush    252
As to the first part....
Quote:
Having a mass parameter for a ship. How can I determine the maximal allowed velocity at every position on the trajectory?

You'll probably want to use the Curvature of the spline, the mass and some "K" factor to determine the maximum velocity.

Something like MaxV = k / (Mass * Curvature)
k will be a "fiddle" factor to get you even vaguely close to the sorts of velocities you want.
Also care needed when curvature is very low... MaxV --> Infinity
So probably best if you also have a fixed "Absolute" MaxV for the ship.

Determining the Curvature of a Bezier Spline..discussed in some detail a while ago...
It took me a while to confirm the math.. (penultimate post).. but it does seem correct.
From that... You're mainly interested in |DT/ds| the magnitude of the curvature, rather than it's direction / orientation.
Which "simplifies" to... (I think)

|DT/ds| = sqrt[ v'.v' - (v.v')² / |v|² ] / |v|²

Where v and v' are the first and second derivatives of P (your Spline Position equation) wrt to t (the parameter 0 -> 1)
v = velocity = dP/dt
v'= "acceleration" = dv/dt

For a "Polynomial" Spline, you can determine v and v' easily....
Section 2.7 of this should be of interest.
NB: Rational Splines are possible.. but are "messy".
Polynomial Splines reduce in degree under differentiation. (n-1)
Rational Splines increase (2n)

As to the second part..."tunnels".. see if you can get your head around this first part.. first.

HTH

[Edited by - daftasbrush on April 22, 2008 7:22:04 PM]

Share this post


Link to post
Share on other sites
h4tt3n    1974
Quote:
Original post by razorjack
The first question is related to a problem where the ship should follow exactly a predefined trajectory.


If I understand you correctly, this is an impossible task. It all depends on what you mean by *exactly*:

You stated earlier that the ship is moving around in a newtonian environment. By this I suppose you mean that the spaceship is always under the influence of gravitational pull from all larger bodies in the system (stars & planets), and that all movement is caused by force, and that you calculate all movement in this order:

force -> acceleration -> velocity -> position.

This also means that you only indirectly can change the direction and velocity of the ship by applying a force with its thrusters - not by changing it directly.

Given these premises you can *never* keep a ship *exactly* on a predefined track. You can implement a penalty method, though, where the ship pushes itself back towards the predefined track once it gets too far off.

If you want it to stay *exactly* on track you'd need to disable 'ole newton.

Share this post


Link to post
Share on other sites
razorjack    143
@daftasbrush:
Wow, that's a nice explanation for the first problem. And it's exactly what I need. I will implement it and see if I could find a solution for the second problem.

@h4tt3n:
Maybe I forgot to tell that I regard only inertia and no other forces. That reduce the degree of complication. In that case I can determine the maximal velocity a ship should fly. daftasbrush made a clear post about the methode.
But, in common case you're right for the exactness.

Thank you all

Share this post


Link to post
Share on other sites

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