So if I have 3 points,like:
x y
z
(imagine a curve formed by them)
How do I create a quadratic for that curve,based just on the locations of those points?
Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
Posted 04 September 2013 - 01:29 PM
Are you looking for a quadratic that goes through those 3 points, or are controlled by those 3 points?
If controlled, a point p on a curve c can be found using t, where 0 < t < 1 from start to finish.
v0 = (1-t)*x + t *y
v1 = (1-t)*y + t * z
and finally:
p = (1-t)*v0 + t*v1
if you are looking for a curve that fits those 3 points, i'm not 100% sure, but I think that more than 1 curve could fit.
EDIT: I stand corrected. Essentially you create the quadratic for each point and then with those 3 equations, Solve for a,b, and c.
EDIT2: I think i feel vindicated, multivariable quadratics would allow for an infinite number of quadratics that fit those points
Edited by Burnt_Fyr, 04 September 2013 - 01:39 PM.
Posted 04 September 2013 - 01:33 PM
We are trying to solve for the constants a,b,c so that the polynomial a+bx+cx^2 gives the appropriate points. Suppose those points are (x1,y1), (x2, y2), (x3,y3).
The typical way to solve this is by using some linear algebra (I know! linear algebra lets you solve quadratics? It's somewhat surprising but we actually know x here and so we don't need to worry about any quadratic behavior. The things were solving for are a, b, and c which are only used linearly in this equation.). If you aren't familiar with this then you'll have to solve it out entirely (and may want to either way if you're not already using a linear algebra library). What this means is that we can plug each point (x,y) into the polynomial and this gives us a constraint on the possible values of a,b,c. So we get:
a + b*x1 + c*x1^2 = y1
Edited by Ezbez, 04 September 2013 - 01:49 PM.
Posted 04 September 2013 - 01:37 PM
Sorry guys,right now i'm in the middle of quadratics,so I might've explained this wrongly.
How do I make an equation for a curve,so i can input points in it and then it will create points for that line.
Imagine I start at x,then advance a little,advance a little untill i reach z,then do the same again,till i reach y.
(Imagine i have a car and i start at x,and i also know 3 points on that curve,so i need to get at the end,but in order to advance,i have to advance a little bit each time till i reach the next point)
Edited by noatom, 04 September 2013 - 01:38 PM.
Posted 05 September 2013 - 08:05 PM
Sorry guys,right now i'm in the middle of quadratics,so I might've explained this wrongly.
How do I make an equation for a curve,so i can input points in it and then it will create points for that line.
Imagine I start at x,then advance a little,advance a little untill i reach z,then do the same again,till i reach y.
(Imagine i have a car and i start at x,and i also know 3 points on that curve,so i need to get at the end,but in order to advance,i have to advance a little bit each time till i reach the next point)
Are you looking for x and y coords from distance, d, traveled along the curve? (arc length)
Posted 08 September 2013 - 01:55 AM
Three points is a good starting example.
A regular circle of the right diameter will pass through any three points.
Finding the radius point with compass and ruler is easy enough.
Anyone good at triangle formula?
Posted 10 September 2013 - 11:24 AM
If I remember correctly, Hermite curves are the simplest ones that go through all the points. It sounds like these might fit your requirements.
http://en.wikipedia.org/wiki/Hermite_curve
Posted 26 September 2013 - 09:20 AM
Quadratic Bezier curves are very simple to do with 3 points. The equation of the curve would be \( C(t) = P_0(1-t)^2 + 2P_1t(1-t)+P_2t^2 \) and you vary t from 0 to 1 to get the whole curve. You can design the curve to pass through your middle point, so you'll have to find the second control point. You can use the Hermite spline formulation to get that second control point.
Edited by cadjunkie, 26 September 2013 - 09:25 AM.
Posted 26 September 2013 - 11:57 AM
You have to be a little bit more precise in asking your question. Here are a few things you might be asking:
* Given three points (x1,y1), (x2,y2), (x3,y3) , where the `x's are all different, find a formula of the form y = A + B*x + C*x^2 that is satisfied by all three points.
* Given three points (x1,y1), (x2,y2), (x3,y3), find a formula like A + B*x + C*y + D*x^2 + E*x*y + F*y^2 = 0 that is satisfied by all three points.
* Given three points (x1,y1), (x2,y2), (x3,y3), find a parametric curve (A + B*t + C*t^2, D + E*t + F*t^2) that passes through all three points.
These are quite different problems, and "create a quadratic for that curve" could mean any of those (and perhaps more) things.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.