# 3D Theory - Car Racing Game - Information from Ian

 RE: car physics - question and answers By: Martin Baker (martinbaker) - 2007-07-07 03:26 Hi Ian,    This is impressive, you are way ahead of me, I think it would be useful to link this message to the web pages, if thats alright with you, as I think it would help others.    It seems to me that one of the reasons this is difficult to model is that it can be very non-linear, for example, as we gradually increase the speed of the wheels then the road speed will increase in a linear way. Then suddenly, at a point determined by the road surface (oil on road etc.), the wheels will start to spin, we are then in a completely different mode (wheel spin) given by a different set of equations. Even if we reduce the wheel speed below the point where they started spinning they will still spin (hysteresis effect). I have just put some equations and diagrams to try to illustrate on this page:  https://www.euclideanspace.com/threed/games/examples/cars/transmission/    It therefore seems to me that we need to identify different modes for the system, such as,   1.engine stall   2.linear acceleration   3.wheel spin   4.breaking   and then derive a set of equations for each together with a set of criteria which switches between these modes.  Do you think that would be a practical approach?    Martin
 RE: car physics - question and answers By: Martin Baker (martinbaker) - 2007-07-16 02:05 Hi Ian,     > Firstly, not sure about your idea of 'switching modes' - I don't think this  > is necessary as the maths should work it all out.    I'm afraid I haven't fully studied the Pacejka 'magic formulas but it just seemed to me that equations alone could not represent the hysteresis effects of friction? From what you say I guess this does not matter?    > One of Brian's articles covers power consumed in overcoming drag. He  > states that to get the drag force into power you simply multiply the drag  > force by the speed, which is of course distance/time, so it makes perfect  > sense as far as the units of power go. I've tried this and it seems to  > work great.    Seems right to me, although of course it is only the power consumed in overcoming drag, can we expand it to include the power required to overcome: drag, tyre friction and that which accelerates the car?  since:  work(energy) = sum ((drag force + tyre friction force + acceleration force) • d x)  where:  • = dot product   d = differential operator   x = change in position vector   force = total force vector = drag force + tyre friction force + acceleration force  so:  d work = force • d x  but power = rate of change of energy = d work /dt  therefore power = force • dx/dt = force • v  so the power is the dot product of velocity and force    > Is it safe to assume then that the same holds true for the acceleration  > force at the drive wheels? - just multiply by the speed and presto we have  > the power? I've added this to power feedback and it seems to work ok but  > I'm just guessing that this is right...?    Can we use Newtons second law: F = m a  Where F is the force left over after drag force and tyre friction force are subtracted.    Martin
 RE: car physics - question and answers By: Ian Greenwood (ijaygee) - 2007-07-23 06:59 Hi Martin, I think the crux to the power issue is how you model the engine. I've taken a pragmatic approach and said that (assuming 100% throttle) the engine can only accelerate if there's a surplus of power available. I've calculated available power as current engine output less current load (from drag and acceleration). I've then taken this 'available power' (which can be zero, positive or negative) and fudged a factor to convert it into revs (e.g. revs += available power * dt/10 - there's no scientific basis to this factor but it works reasonably well and I suppose mimics the acceleration of the flywheel, drive train, and internal friction etc.)    I ran some numbers based on accelerating the drive wheels with the torq on the axle. I think I need to divide this between the rear wheels but, taking the rear wheels as a unit the power is of course P = Tw. Needless to say this power is identical to the engine output (all we did was reduce the revs by the gears ratios and increase the torq by the same factor). Now, that's not the same as the power coming back from the tyre model by P = Fv because this encorporates slipping and is usually less than or equal to the power being delivered to the wheels by the engine.    As far as I can see, the linear form, P = Fv (i.e. P = F . d v) based on the force at the wheels plus drag and the velocity of the car is correct. This wheel force is zero when we're cruising at a constant speed - the tyre model does that for us. The only power consumption then is in overcoming drag.    I guess we've got 2 modes here esp. with respect to racing. The first is when we've got the throttle open, accelerating as fast as possible and placing full demand on the engine. The second is when we're braking (for corners) - the engine is usually helping with braking. The only time a racing car cruises is when we're flat out, consuming all the power the engine has to give to overcome drag and friction.    I'm getting a clearer picture of what's going on and where I need to go.    In the current setup, I'm spinning the drive wheels based purely on the engine revs through the gears. This gives artificially high acceleration (it's all down to revs and that dt/10 fudge factor). So, now I'm thinking about accelerating the wheels with the torq on the axle. From the tests I've been running we can spin a wheel up to full revs in less than a second in 1st (but that's with 1 wheel getting all the torq so, it'll probably be more like 2 seconds to spin up both wheels receiving half the torq each via the diff). Now this is going to have an effect on engine revs, after all, the wheels can't spin faster than the axle and vice versa. Now I see where your hysterisis loop fits in to the picture and, we've got a physical reason why the engine revs can only increase at a certain rate (no more fudge factors!). Also, I see that power is directly proportional to revs so, when we use power we actually use up revs.    By Jove I think I've got it!

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

Game Programming for Teens.

other games programming books

Commercial Software Shop

Where I can, I have put links to Amazon for commercial software, not directly related to this site, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them.

 Dark Basic Professional Edition - It is better to get this professional edition This is a version of basic designed for building games, for example to rotate a cube you might do the following: make object cube 1,100 for x=1 to 360 rotate object 1,x,x,0 next x Game Programming with Darkbasic - book for above software

other commercial software

This site may have errors. Don't use for critical systems.