The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.

Parabola between two points in a plane

RiemannLivesRiemannLives Registered User regular
edited September 2010 in Help / Advice Forum
Given two points, p1 and p2 (each of which have components x and y), how would I find a set of parametric equations of t for the x and y components of a parabola between them?

(note: this is not 'homework', this is actually going to be used in plotting the path of an animation in a program I am writing)

EG: how to find the equations x = f(t) and y = g(t) that will plot a parabola between the points p1 and p2 in a 2d space.

Attacked by tweeeeeeees!
RiemannLives on

Posts

  • EndEnd Registered User regular
    edited September 2010
    I'm not very mathy, but don't you need three points to uniquely define a parabola? And that's assuming it has a horizontal axis of symmetry.

    I guess if you define one point as the root, you could bring it down to two.

    End on
    I wish that someway, somehow, that I could save every one of us
    zaleiria-by-lexxy-sig.jpg
  • RiemannLivesRiemannLives Registered User regular
    edited September 2010
    End wrote: »
    I'm not very mathy, but don't you need three points to uniquely define a parabola? And that's assuming it has a horizontal axis of symmetry.

    I guess if you define one point as the root, you could bring it down to two.

    You are right in that 2 points will not identify a unique parabola, but it should just have a constant left in the equation basicially indicating how "stretched" it is normal to the line between the two points.

    RiemannLives on
    Attacked by tweeeeeeees!
  • LykouraghLykouragh Registered User regular
    edited September 2010
    by "between" you mean that both points lie on the parabola?

    Lykouragh on
  • LykouraghLykouragh Registered User regular
    edited September 2010
    assuming the above is true, procedurally i would just solve the quadratic y=ax^2+bx+c in the normal way given your two points (use each point to eliminate x and y and generate an equation of two variables and a parameter) and spit out the parametrized solution

    offhand i have no idea how to tell a computer to "solve a quadratic" though

    let's assume we're parametrizing in c and i'll try to do it by hand though

    we have (x1, y1) and (x2, y2)

    y1=a(x1)^2+b(x1)+c
    y2=a(x2)^2+b(x2)+c

    solve for a and b, plug back into y=ax^2+bx+c, to obtain parametrized version solve for x and y in terms of c

    Lykouragh on
  • AiouaAioua Ora Occidens Ora OptimaRegistered User regular
    edited September 2010
    Now, I don't know my maths, but I just want to clarify one point.
    I assume you're talking about having the points equidistant from the center like so:
    15yal1.jpg

    In which case I would think you could contrive some equasion with a 3rd variable that would determine its steepness.

    However, if you're trying to apply a parabola to the points unevenly:
    1fi79t.jpg

    I have a feeling finding an equasion would be nigh impossible, or at least a very different and harder equasion.

    Also you could just draw a straight line. It approximates a very, very, very, very shallow parabola ;)

    Aioua on
    life's a game that you're bound to lose / like using a hammer to pound in screws
    fuck up once and you break your thumb / if you're happy at all then you're god damn dumb
    that's right we're on a fucked up cruise / God is dead but at least we have booze
    bad things happen, no one knows why / the sun burns out and everyone dies
  • ClipseClipse Registered User regular
    edited September 2010
    Like Aioua said, it's much easier if you assume that the vertex of the parabola projects to the center of the line segment between x1 and x2.

    Let x1, x2 be vectors in R^2, take n to be normal to x2-x1 (choice of normal doesn't matter), then

    t*(x2 - x1) + x1 + a*t*(t-1)*n

    with a being the stretch factor is the family of parabolas you're looking for.

    If you can't assume that the vertex of the parabola projects to the center of the line segment... well, good luck!

    Clipse on
  • RiemannLivesRiemannLives Registered User regular
    edited September 2010
    Ah, thanks for the help guys. I think I found my answer: Bezier curves.

    http://en.wikipedia.org/wiki/B%C3%A9zier_curve

    RiemannLives on
    Attacked by tweeeeeeees!
  • ClipseClipse Registered User regular
    edited September 2010
    Ah, thanks for the help guys. I think I found my answer: Bezier curves.

    http://en.wikipedia.org/wiki/B%C3%A9zier_curve

    Man, I haven't done anything graphics related in so long I didn't even think about splines. Since you only care about the startpoint and endpoint, you might want to consider stepping up to cubic and using Hermite splines instead, though. They allow you to control the tangent at the startpoint and endpoint, which can be very useful for animation.

    Clipse on
  • RiemannLivesRiemannLives Registered User regular
    edited September 2010
    Clipse wrote: »
    Ah, thanks for the help guys. I think I found my answer: Bezier curves.

    http://en.wikipedia.org/wiki/B%C3%A9zier_curve

    Man, I haven't done anything graphics related in so long I didn't even think about splines. Since you only care about the startpoint and endpoint, you might want to consider stepping up to cubic and using Hermite splines instead, though. They allow you to control the tangent at the startpoint and endpoint, which can be very useful for animation.

    ah, good point. Especially since I already have the values for the tangent at the start and end pre-calculated (as they are the speed and facing of the object at the start and end points).

    RiemannLives on
    Attacked by tweeeeeeees!
  • SavantSavant Simply Barbaric Registered User regular
    edited September 2010
    Yeah, like has been said before, you need 3 points to interpolate a parabola. If you want to fit those points exactly, then what you'll do is Polynomial interpolation, which is sort of an extension of the earlier idea of setting up systems of equations, but using matrices instead. You probably only want to do that at the higher end when you aren't fitting data but simply want the exact polynomial through a set of points.

    Least squared error type regression and B-splines are better for other types of problems where you want to fit a non-polynomial with a simpler function, depending upon what you are trying to do. B-splines are piecewise polynomial functions, not a single polynomial, by the way.

    Savant on
Sign In or Register to comment.