Figuring out the maximum acceleration allowable in a tight space

Started by
2 comments, last by Norman Barrows 7 years, 1 month ago

I've run into a problem that I'm having trouble solving. If you have an object with different acceleration/decceleration values, and it's moving from point A to point B, and you already know from previous calculations that it wouldn't have enough space to decelerate fully from its max speed. I'm trying to figure out how much acceleration it can do, so that it still has room to decelerate fully in time. The point is to get there as fast as possible, without overshooting.

Assuming the deccel is less than or equal to the accel, I could do:


accelSpace = distance * deccel/accel
deccelSpace = (1-accelSpace) * distance

This way, if accel is 10 and deccel is 2, you'd accel for 0.2 of the distance, then decel the rest.

But this only really works if the object isn't moving at all yet. If it's already moving, I'd have to figure out how much acceleration I can still get away with, while still having room to decelerate.

I think this might be like one of those optimization problems from Cal I. I'll describe where I'm at with solving this problem. I'll start with some equations:

How to know how much space you need to accelerate to a certain speed:


time to accel:    t = (spd - curSpeed)/accel
accelSpace = 1/2(t^2)   

Decceleration space from a certain speed:


time to deccel: t = spd/deccel
deccelSpace = 1/2(t^2)

Now here I am trying to solve this:

If I can get the max decelerable speed with:

dist - deccelSpace = 0

substituting the previous equations we get:


dist - 1/2(spd/deccel)^2 = 0
spd^2/2deccel = dist

spd = sqrt(2dist) * deccel

So that gives us the max speed I could decelerate from in that space. spd <= actual speed, we should just decelerate now, and not do any further calculations.

However, if spd > actual speed, we can probably accelerate a bit more before the end. So I turn to optimization problems from Cal I.

a = acceleration

d = deceleration

S = current speed

S1 = desired speed (unknown)

deltaS: S1 - S

we've got the functions we want to maximize:


accelSpace = deltaS^2/2a^2 
decelSpace = (S + deltaS)/2d^2

we've got a constraint:


dist - accelSpace - decelSpace = 0

So I solve the constraint for accelSpace:


acccelSpace = dist - decelSpace;

Plug in the accelSpace function, solve for deltaS


deltaS^2/2a^2 = dist - decelSpace
deltaS^2 = 2a^2(dist - decelSpace)
deltaS = a * sqrt(2)sqrt(dist-decelSpace)

At this point, I think I'm supposed to substitute deltaS into the accelSpace function, then get the local maxima from a derrivative, then plug that into decelSpace, but I'm at a loss for what to do afterwards, because doing

just the first step leads me right back to the constraint


accelSpace = (a*sqrt(2)sqrt(dist - decelSpace)^2 / 2a^2
accelSpace = dist - decelSpace.

So there you have it, I'm lost. :/

Advertisement

I've given this some more thought, and I think the answer may be much simpler than I surmised.

The idea of accelerating for a 0.X of the way, and deccelerating 0.Y of the rest can work even when already moving. You just have to move the start point back by the accelSpace it would have taken to reach your current speed from 0, and pretend you're starting from there for the purpose of the math.

a/d is the accel/decel point.

If the speed is 0, it works like this:

O---------a/d-----------------------------------------------------B

If we're already cruising along, we shift back by one accelSpace, plugging our current speed into the accelSpace I mentioned earlier.

Calculate it from O, as though we were starting from 0. (A is our actual location)

d

__________

| |

O---A-----a/d----------------------------------------------------B

accelDist = d - OA

I don't know if you're still having problems, but what you are describing sounds like a Trapezoidal Motion Profile.

Maybe that search term will help you.

initial velocity + accel rate applied for some amount of time t1 = distance traveled accelerating

velocity when decel begins + decel rate applied for some amount of time t2 = distance traveled decelerating.

distance traveled accelerating + distance traveled decelerating = range to tgt.

velocity when decel begins is simply whatever your velocity is when you finish accelerating.

then you solve for t1 and t2, such that accel dist + decel dist = rng to tgt.

For that you need a math junkie - As i recall, distance traveled based on accel and time will be a double integral.

i can do math, but don't like it. its been so long, i'd have to look it up. I'm sure some math junkie here can tell you how to solve the rest.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

This topic is closed to new replies.

Advertisement