PDA

View Full Version : what's the equation?



xytor
March 28th, 2007, 10:31 PM
I have some data, but I can't seem to figure out the function eqation that matches the data.
There are 2 variables, R and D.
here is a chart:
R | D
_______
5 | 50
15 | 50
45 | 45
50 | 41

so in other words, when R is 5 then D is 50. But.. given that data I can't figure out the equation f(R)=D.

Just if your'e wondering, this is for a flash game I am making; it has to do with the _rotation of something and the y velocity of something else...

TheCanadian
March 28th, 2007, 11:49 PM
That's not enough data to construct a function unless you define it piecewise for R=5,15,45,50 - in which case you won't be able to take on any intermediate values.

If you know the type of curve it should be, you could do a regression of some sort to determine an approximating curve.

Krilnon
March 29th, 2007, 12:50 AM
unless you define it piecewise for R=5,15,45,50

:lol: :)

TheCanadian
March 29th, 2007, 01:14 AM
:pleased:

xytor
March 29th, 2007, 02:03 AM
Well no, thats the point... I have those values, but I need to know all values for f(R)=D....
the curve looks like a logarithmic because it caps off at 50, and slowly decays down...

TheCanadian
March 29th, 2007, 02:13 AM
Okay so do a regression, something like:

2.75ln(x)+40

xytor
March 29th, 2007, 02:20 AM
it actually doesn't look like that...
maybe more like 5ln(x)^2 rotated 90 degrees?

TheCanadian
March 29th, 2007, 02:34 AM
D=-5ln(0.06R)^9+50 gets you pretty close. Just define the function as a straight line for R<=15.

xytor
March 30th, 2007, 10:18 AM
D=-5ln(0.06R)^9+50 gets you pretty close. Just define the function as a straight line for R<=15.\\

No... It's not that...

what I am tring to do is make an object's y-velocity be based on the rotation of another object.
so i set the yVelocity=rotation/divisor
thats what R and D are.
i am trying to find the number to divide the rotation by to make the yVelocity accurate ( so it stays on the slope instead of flying or burrowing)

puppy
March 30th, 2007, 10:38 AM
what about Lagrange (http://en.wikipedia.org/wiki/Lagrange_form):


function f(x) {
return 0 +
50 * (x - 15) * (x - 45) * (x - 50) / (( 5 - 15) * ( 5 - 45) * ( 5 - 50)) +
50 * (x - 5) * (x - 45) * (x - 50) / ((15 - 5) * (15 - 45) * (15 - 50)) +
45 * (x - 5) * (x - 15) * (x - 50) / ((45 - 5) * (45 - 15) * (45 - 50)) +
41 * (x - 5) * (x - 15) * (x - 45) / ((50 - 5) * (50 - 15) * (50 - 45));
}

xytor
March 30th, 2007, 09:09 PM
Works good enough, thanks puppy.
Can you explain a little of the concept behind that?

Element9
April 1st, 2007, 08:31 AM
That's polynomial interpolation. Finding a polynomial that passes through given points.

http://en.wikipedia.org/wiki/Lagrange_form

xytor
April 1st, 2007, 10:14 AM
thats perfect, thanks