Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!

Constant acceleration: Point out why I am an idiot

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Pasanova   Members   -  Reputation: 119


Posted 16 September 2012 - 04:57 AM

Sorry to reference such an old thread but http://www.gamedev.n...ering-behavior/
refers precisely to the thing I am having trouble understanding!


//calculate the speed required to reach the target given the desired
double speed = dist / ((double)deceleration * DecelerationTweaker);

How does this calculate the speed? I just cannot understand it, besides doesn't
x/a have the dimensions of time squared?
I think it should be completely different, I am obviously missing something
u-Initial (current) velocity required (what we want to calculate above)
v - Final velocity (in this case zero)
x - Distance to target "dist" in the above?
a - The acceleration, in the above a = -deceleration * DecelerationTweaker?
Constant acceleration equation:
v^2 = u^2 + 2ax
u = sqrt(2*deceleration * DecelerationTweaker*x)
Can anybody point out the error?


#2 Bacterius   Crossbones+   -  Reputation: 10554


Posted 16 September 2012 - 07:55 AM

It looks like he defined "deceleration" not as an acceleration (m/s^2) but as a unit of time (s), which then agrees dimensionally as v = d/t. His code doesn't actually seem to be considering agent acceleration. All it does is measure the distance from the agent to the target, use v = d/t to obtain the velocity needed to traverse the distance in the required time assuming zero acceleration, and orients the velocity using the direction vector from the agent to the target. It also makes sure the speed is bounded to the maximum speed of the agent.

So as far as I can tell, his code assumes the agent is never accelerating, which makes for some pretty basic steering, not what you are looking for.

By the way, you can ignore decelerationTweaker in your code, as for some reason DrunkenBrit uses it to extend his enum to floating-point precision, which has nothing to do with the physics at all (looks like a code crutch).

You are not an idiot.

Edited by Bacterius, 16 September 2012 - 08:18 AM.

The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.


- Pessimal Algorithms and Simplexity Analysis

#3 Pasanova   Members   -  Reputation: 119


Posted 16 September 2012 - 08:52 AM

Thanks Bacterius!
I have just reread that section and you are exactly right! Thank you so much!
It makes a lot more sense to me now :) It is a very good book in general
even if the variable names are very misleading here!

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.