Sign in to follow this  
Windexglow

Math-slope help

Recommended Posts

Windexglow    138
I'm making a simple arcade-ish flight simulator in Starcraft2's editor. For the life of me however I can not figure out how to model acceleration. The script activates every 0.05 seconds to adjust varying values, of which these are the constants. Engine_Add - Adds thrust to the vehicle. Engine_Mod - I know I'll need this one for the control. Engine_Max - Cuts off acceleration at this point I want the craft to be able to rapidly accelerate, but slow down in it's acceleration the closer it gets to Engine_Max. In short: An equation that starts at zero, gives me some control over it and tapers to a pre-set max, much like either 2 lines in this image. http://img18.imageshack.us/img18/672/14404016.jpg Even the name of the kind of math I'm trying to work with would be great. If I need to give any information just ask.

Share this post


Link to post
Share on other sites
haegarr    7372
There are several functions which may be of interest:

a) sin(x) for 0<=x<=pi/2 starts with a slope of 1 and ends at 0, and its value starts at 0 and ends at 1, and hence may be suitable to work well as a scaling factor with Engine_Max (it is similar to the lower curve in your image).

b) sqrt(x) for 0<=x<=1 may also work well as a scaling factor with Engine_Max

c) A quater circle (shifted) is probably not so good, but for the case you want to experiment with it:
sqrt(1-(x-1)^2) for 0<=x<=1 (it is similar to the upper curve in your image).

d) The plenty of spline functions will work, of course. Also other higher order polynomials with even power terms may work.

e) Piecewise functions can give more control, e.g. if the initial acceleraton should start at 0, too. In that case you have to ensure smoothness not only in location (e.g. G0) but also in derivatives, or else artifacts may become visible.

Share this post


Link to post
Share on other sites
Ariste    296
If I understand correctly, you're looking for an acceleration function that begins at 0 and tapers off as a function of the difference between the current acceleration and Engine_Max. We can describe this with an initial value problem like:



where M = Engine_Max. The solution is:



Is this what you're looking for?

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