Peblo Custom ratings must be 50 characters or less
Registered 05/07/2002
Points 185
20th November, 2005 at 17:23:26 -
I'm building another application, and I have run in need of an extension, or example or something. Basically, I need something where you put in a few X and Y coordinates, and it tells you the equation of the line. Anything like this exist?
"Isn't it always amazing how we characterize a person's intelligence by how closely their thinking matches ours?"
~Belgarath
well im guessing you dont have a clue about linear functions cause lines are the easiest. have it do this. X2-X1=X3, Y2-Y1=Y3; Y3/X3 equals your slope
(12,6),(4,2)
4-12 = -8 ; 2-6 = -4
(-8,-4) -4/-8 = .5 <<--your slope
then you need to put it back into place.
y+6=.5(X+12)
friendly format y=.5(x+12)-6
now when you get into 3 or more sets of x,y coordinates at a time your gonna get into regressions and i know how to make a calculator do em but unless they are all linear i cant give you a methid of how to do it
but i said it in a longer paragraph and much more mathematical gibberish..ish....ish. by the way, do YOU know how to solve regressions without a calculator. id like to know if you did.
n/a
Peblo Custom ratings must be 50 characters or less
Registered 05/07/2002
Points 185
20th November, 2005 at 19:53:38 -
I know how to do straight lines, I meant about parabola's(sp?) and stuff, for like 3 or more XY coordinates.
"Isn't it always amazing how we characterize a person's intelligence by how closely their thinking matches ours?"
~Belgarath
basic parabola is y=x^2 (smiley parabola) y=-x^2 (frowny parabola)
quadratic formula stuff and using systems.ill post it later when i can write something good down and explain it well. unless someone else nails it before i do.
---------------------------------------------
ok here it goes.
this only works for 3 coordinates as far as i know. and you have to have knowledge of matrice multiplication.
now we use the matrice multiplication of [A]^-1 * [C] ;(^-1 = inverse of [A]not [A] raised to the negative one)
____[ 1 1 1 ]
[A]=[ 144 12 1 ]
____[ 36 6 1 ]
____[ 4 ]
[C]=[ 4 ]
____[ 2 ]
_____________________[ .0666666667 ] = a
so [A]^-1 * [C] gives us [ -.8666666667 ] = b
_____________________[ 4.9 ] = c
so our equation for the parabola through these points is
y = .0666666667X^2 + -.8666666667X + 4.9 (y = ax^2 + bx + c)
--------------------------------------------
note: if your thinking your gonna be able to connect the dots of a random scatter plot your best bet would be to go with linear functions connected by piecewise models.
so im guessing since you arent responding this doesnt help you...too complicated?
n/a
Peblo Custom ratings must be 50 characters or less
Registered 05/07/2002
Points 185
22nd November, 2005 at 01:39:30 -
Uhh, actually I forgot all about this topic.
Anyways, I understand most of it, except matrice multiplication and implementing it. The thing I need this for is this: the user holds down the mouse button, and if they move the mouse (variable) pixels, it creates a point. When they let go of the mouse button, about 5 points will exist. I need something that will take those X and Y coordinates and make them an equation, which will be matched against 8 hardcoded possibilities. Whichever equation matches the user input the closest will execute some code.
Basically, I need something that takes (var)XY points, and puts them in a string that can be compared to a database of sorts.
Edit: Sorry, I think I mean expression instead of equation in anything I said. I think so anyways.
Edited by the Author.
"Isn't it always amazing how we characterize a person's intelligence by how closely their thinking matches ours?"
~Belgarath
equation and expression are pretty much the same thing. i think but like i said your probably looking at using something like piecewise functions. They are a string of functions that pretty much play connect the dots, but like i said before your prolly not gonna be able to use a function or an equation to make a single equation to connect all these points.