Realistic Car help.

Started by
4 comments, last by sgb27 15 years, 11 months ago
I was going to program a car setting up a random horsepower number and torque lbs,among other things. But I realized I do not know that much about cars to calculate the cars max speed, acceleration, and how long it would take to reach its potential,how much gas it would use going a certain speed. Does anyone know the calculations to figure it out?
Advertisement
What do you actually want to have at the end?
If you want a 3D simulation of a car, I would recommend you a physics library like Newton Game Dynamics. (there are a lot more, like ODE, Bullet. Haven't tested them all)
But if you want just to calculate the max velocity and acceleration of the car with certain input like the horsepower and other things I think you would have to do some complex physical calculations. I would just solve it practically making a simulation.
Hope I understood your question.

[Edited by - aeroz on May 8, 2008 11:28:47 AM]
I would just need the actual equations for it, I am just creating a console program to output the calculations.
Well, I don't know the calculations but there's quite a comprehensive article about the "Physics of Racing Series". You can find a lot of information there. But even things like calculating the theoretical max speed of a car isn't as easy as it seems...
baumep
I think for a small hobby project, as I assume this is since it is in this forum, you should just use logic to create your own equations. There are so many factors that could play into different equations that it wouldn't make sense to try to simulate it. For example, fuel economy can change even due to just tire pressure.

You could always just research some specs of cars similar to those you are trying to simulate and steal their acceleration times, top speeds, etc. If you really want to accurately figure it out, make some sort of plot and find some sort of regression line for horsepower vs. top speed or something.

I think what I'm saying is that unless you really want to learn a whole lot about cars, and if you just want to make a program, it doesn't need to be 100% realistic. You won't want to spend that kind of time on it.
Quote:Original post by monp
I was going to program a car setting up a random horsepower number and torque lbs,among other things.

What you need to decide is the torque output of the engine at every rpm - this is usually shown in the form of a chart of torque against rpm. I would just find a stock graph from any car and then scale it by a random amount to get whatever maximum torque you require.

Horsepower is calculated from the torque, Power = torque * engine speed. If you're using non-metric units you'll need some scaling factor in there too. I recommend you use all metric SI units internally though (watts, newton metres, radians per second, metres per second) and then scale to more familiar units just for input/output.

Quote:
But I realized I do not know that much about cars to calculate the cars max speed, acceleration, and how long it would take to reach its potential,how much gas it would use going a certain speed. Does anyone know the calculations to figure it out?

The easiest way to work out all those is to run a simulation. You keep track of the vehicle speed at each time-step, and then at each step work out the following (in this order):
1) The gear the car should be in (either worked out automatically or based on user input)
2) The engine speed (rpms) from the car speed and gear
3) How much torque the engine is generating at this rpms (from your graph above, plus optional user input for % of throttle)
4) How much forward force this generates on the car (depends on gear ratios and tyre size)
5) How much air drag there is (depends on some constant (try 0.5) times vehicle speed squared)
6) The acceleration of the car (depends on 4 and 5 and the mass of the car)
7) The new speed of the car (old speed + acceleration * time step)

That is very simple, but it's a good starting point, and if you use a small enough time-step (eg 0.01 seconds) you should get pretty accurate results.

Edit: For fuel use, a good first approximation would be to assume the rate of use is proportional to the engine output power.

This topic is closed to new replies.

Advertisement