Hey there everyone. I hope i got the right forum here. I really, quite desperately need this graph -
turned into an equation i can use in my lua programming script. If anyone could do this for me, i'd be eternally greatful.. thank you.
It doesnt represent anything really, its just out of my mind. Its a weight to speed ratio graph. The less lines that are in my piece of code, the more efficiently it will run. I just really need something thats one line and tells the code to replicate that, that isnt
if(weight) =>50
then(speed) ( 1 )
elseif(weight) ==49
then(speed) ( 2 )
Something with so many lines of code will run sluggishly.
First, there are an infinite number of functions that would give graphs that look like what you have given. However, you can look for the easiest. It clearly is not a straight line so lets try quadratic. Any quadratic will be of the form so we need three data points to determine those three coefficients. Just looking at your graph it looks like weight is 50 when speed is 0, weight 25 when speed is 25, and weight is 0 when speed is 35.
But apparently you want speed as a function of weight (your graph has "dependent" and "independent" axes swapped from the usual convention) so you want (50, 0), (25, 25), and (0, 35).
Putting those values into the equation,
and
Multiplying the second equation by 2 gives 1250a+ 50b= -20 while the third equation is 2500a+ 50b= -35. Subtracting eliminates b: 1250a= -15 so that .
Putting that back into 1250a+ 50b= -20 (or just 125a+ 5b= -2) we have so and .
So one possible function is . That will exactly fit the points I chose:
but probably will not go exactly through other points.
For example, from your graph it appears that a weight of 15 corresponds to a speed of 30. Setting x= 15, instead- close but not exact. If you wanted that point to be exact also, you could go up to third power giving you another coefficient and another point to use. But then there would be other points at which the function would not be exact.
I suspect that , where "x" is the weight and "y" is the speed, is the best simple function you will find to fit this graph.