Hey all, I'm trying to make a racing driver management sim and I've got the basics working in a C# console app. You give the code a track, driver and a car and it'll spit out X number of laptimes. Now, I'm trying to model tyre degredation in to the laptimes and I know how I want to do it, unfortunately my GCSE maths is letting me down. What I need is to get values in the range 0-10 for the grip level based on the current lap and the tyres being used. Here's a basic graph I knocked up in PS to demonstrate the model: *edit* Just realised I forgot the key - Soft, Medium, Hard Now from my research I think I need to use the trigonometry functions of Math, however I don't understand what/how to make them work for this scenario? Virtual cookies/beers are on offer for anyone can give me a nudge, link, or example code showing how I can do this Thanks guys.

I'm no expert on this, but you simply(!) have to find the equation which matches the graphs as near as possible. There are quite a few equation-to-graph converters on the web - http://www.meta-calculator.com/online/ seems to work well. I've had a quick play and come up with... y = sin((x - 6) / 4) * 4.5 + 5.5 ...which gives you a pretty good sine wave which fits your co-ordinates. If you can work out how to skew the graph to the left or right then you should be able to match it up to your graphs pretty well. Then just use this equation in your code and your all sorted!

Thanks for the help! I managed to solve this using Excel in the end - shock, horror! The graphing tool has a handy feature which lets you create a polynomial trend line from a dataset, and it will also generate the equation for the curve for you too. I ended up with this: Thanks again, beer and cookies are on me!

Hmmm it appears I spoke too soon. The equation excel spits out only maps the first part of the curve... is that all that's possible with one equation? Original: And then that equation plotted:

Thanks, that looks bang on, what kind of curve/equation is that? Do you have any examples of how to calculate it from a set of figures?

Aha! I think I've cracked it, thanks mostly to this online too, which spits out polynomial equations based on supplied x,y coords. That gave me this: Which becomes this: Hurrah!

That looks like quite a complex function. It might be more efficient to just store the grip values in a lookup table? edit: actually, i misread the OP. I thought it was a racing game rather than a racing management game. Maybe the efficiency of the calculation is not that important.

That was my plan B. I may still do it that way, depending on how the modelling of the other tyre compounds goes.

I'd ditch the equations and go with the suggested lookup table. It has a number of advantages; 1. No strange formulas in the code 2. Probably quicker 3. Easier to tweak