#### Archived

This topic is now archived and is closed to further replies.

# Realistic Car Acceleration?

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

## Recommended Posts

I was just wondering how to make my car accelerate at a realistic speed, eg. accelection slowing down as it approaches the top end speed etc... I''ve looked at a few car physics tutorials but they didn''t shed much light on the matter. Any help would be greatly apreciated.

##### Share on other sites
Lets say you already have your force from the engine accelerating the car fowards. If you just had this force, your car would carry on accelerating forever. Now you want to add air resistance. Air resistance is a force going backwards, and is proportional to the square of your fowards speed. So, the faster you go, the air resistance gets bigger and bigger, until eventually the air resistance balances the foward force and your cars speed levels out. Ofcourse that model isn''t totally accurate (you may wish to add the rolling resistance of the tyres, account for changes in torque due to gear shifts, etc.) but including air resistance will make the model a whole lot more realistic for only a little coding time.

Air resistance = -(Speed ^ 2) * Constant

which you may want to optimise to

Air resistance = -(Speed * Speed) * Constant

##### Share on other sites
Thanks, but I''m not quite sure how to work out the force applied by the car. I know its along the lines of:

Engine Torque * Gear Ratio * Differential Ratio

I had a method similar to this in my little game, but it was still fake because the way I calculated the Torque used the RPM, and the RPM was calculate simply as RPM+=10 when the up arrow was pushed Giving a constant acceleration, which isn''t true because as we see when driving a car (and playing game) the closer you get to the redline of the enigine the slower the RPM increases.

So I''m not quite sure how to go about it?

##### Share on other sites

edit: Don't miss the links at the bottom, they also look quite good.

[edited by - MisterAnderson42 on August 31, 2002 10:50:37 PM]

##### Share on other sites
Yeah, I''ve looked at that site but I couldn''t understand something about it. They say you need the RPM to calculate the torque, but you need to know the torque to calculate the RPM? Its probably that I''ve just missed something, or didn''t understand it properly?

##### Share on other sites
Welcome to the world of Differential equations, where the speed can depend on the acceleartion, and at the same time the acceleration depends on the speed (I''m thinking of air resistance). Solving equations like these symbolically can be quite difficult if the equation is complex. Though, from the standpoint of a coder using discrete timesteps to calculate the position, it is no different from doing the normal laws of motion.

For cars, assuming no torque converter or clutch, the RPM of the engine is directly related to the cars speed and the current transmission gear ratio, right? Everything is physically connected. So your engine RPM is given for you by that. Now, you have a table of the torque that the engine can supply at a given RPM. Depending on the throttle position, supply some fraction of that torque to the transmission, which gears it down, applying it to the wheels, which apply a force to the road. Now, this force will make the vehicle accelerate, and you can now calculate, position and speed for time t+1. Now, the change in speed will affect the RPM of the engine. BUT.. don''t worry about that at time t (it will be obviously be taken into account at time t+1). We just pretend for the sake of approximation that the RPM doesn''t change at all during time t.

##### Share on other sites
A quick and dirty cheat would be to simply multiply the velocity of the car by say 0.9 at each timestep. Adjusting this number will change the maximum achievable speed. You''ll probably need to adjust the applied acceleration force as well in order to get a realistic feeling.

##### Share on other sites
quote:
Original post by MisterAnderson42
Welcome to the world of Differential equations, where the speed can depend on the acceleartion, and at the same time the acceleration depends on the speed (I''m thinking of air resistance). Solving equations like these symbolically can be quite difficult if the equation is complex. Though, from the standpoint of a coder using discrete timesteps to calculate the position, it is no different from doing the normal laws of motion.

For cars, assuming no torque converter or clutch, the RPM of the engine is directly related to the cars speed and the current transmission gear ratio, right? Everything is physically connected. So your engine RPM is given for you by that. Now, you have a table of the torque that the engine can supply at a given RPM. Depending on the throttle position, supply some fraction of that torque to the transmission, which gears it down, applying it to the wheels, which apply a force to the road. Now, this force will make the vehicle accelerate, and you can now calculate, position and speed for time t+1. Now, the change in speed will affect the RPM of the engine. BUT.. don''t worry about that at time t (it will be obviously be taken into account at time t+1). We just pretend for the sake of approximation that the RPM doesn''t change at all during time t.

How would the car accelerate using that method? I''m probably wrong, but as I see it you are calculating the RPM of the current speed of the car, and then using that to set the new speed in the car. So wouldn''t the RPM just stay the same the whole time?

##### Share on other sites
[*quote]Air resistance = -(Speed * Speed) * Constant

as Bazee said is not entirely true.

If your car can go backwards, it will have a negative speed value so squaring this you would lose the sign..
here''s a macro for ya
SQRMAG(x) x>0? x*x : x*-x

J.

return(0);

##### Share on other sites
quote:
How would the car accelerate using that method? I'm probably wrong, but as I see it you are calculating the RPM of the current speed of the car, and then using that to set the new speed in the car. So wouldn't the RPM just stay the same the whole time?

Think about it. Use the current RPM to update the speed (because the engine can apply a torque which eventually becomes a force on the road). Since the engine and tires are mechanically linked (ignoring clutch and torque converter) and each turn together, you can find the new RPM of the engine given this new speed. This will be used in the next timestep to find the available torque again.

quote:
If your car can go backwards, it will have a negative speed value so squaring this you would lose the sign

Correct. More formally, air resistance is a frictionaly force which always opposes motion. So, it has maknitude k * speed**2, and direction -V hat, where V hat is the velocity unit vector. In full vector notation: Fa = k * (V dot V) * (-)(V / ||V||)

[edited by - MisterAnderson42 on September 2, 2002 10:28:39 AM]

1. 1
2. 2
frob
20
3. 3
Rutin
17
4. 4
5. 5

• 13
• 10
• 9
• 18
• 9
• ### Forum Statistics

• Total Topics
632555
• Total Posts
3007035

×