On Fri, 02 May 2008 17:27:18 +0200, Robert Larsen
<robert@[EMAIL PROTECTED]
> wrote:
>Hi group
>
>I seem to have lost all math skills :-(
>
>I am trying to determine the coefficients of a quadratic polynomial
>given the following data:
>
>x1,y1 - One point on the curve
>x2,y2 - Another point on the curve
>y3 - The Y coordinate of the top coordinate
>
>y3 > y1 and y3 > y2
>x2 > x1
>
>I believe this should yield exactly one solution but have no idea how to
>find it. Can you help me ?
>It should be used for calculating the path for an animation in a
>computer game.
>
>Sincerely,
>Robert
I will change your notation a little for easier typing and display.
Call your first point (a,b) and your second point (c,d), and the
height of your vertex by h (what you called y3). Now you want a
quadratic equation of the form
y = px^2 + qx + r
and you want to get p, q, and r knowing a,b,c,d, and h. This leads you
to the following three equations in the unknowns p, q, and r.
pa^2 + qa + r = b
pc^2 + qc + r = d (these come from the first two points)
-q^2 + 4pr = 4ph (this comes from your vertex requirement).
For example if (a,b) = (0,1) and (c,d) = (3,4) and h = 5, you will
find that p = -1, q = 4, and r = 1, giving the parabola:
y = - x^2 + 4x + 1.
However, if you try to solve the equations symbolically for p, q, and
r in terms of the other variables, you invariably run into a cubic
equation. For example, put (0,1) and (3,4) in that system and leave h
unknown and try to solve it by hand to see what happens when you try
to get p, q, and r in terms of h. So it looks to me like you are going
to have to use some numerical method. It isn't as easy as it would
appear to be at first glance.
--Lynn


|