1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Fitting quadratic curve to three constraints

  1. Dec 12, 2007 #1
    This should be easy but I've not done this in years and I'm feeling dense:

    I need to fit a quadratic curve to three constraints, two of which are points, the third is an angle.

    I've found examples to do this but only if all three constraints are points, so if someone would kindly explain the process I'd be a happy man. :)

    Edit: I should add I've got an old example in front of me where I did just this (for a cubic equation though) but due to poor notes on my part I can't quite understand what I was doing.
    Last edited: Dec 12, 2007
  2. jcsd
  3. Dec 12, 2007 #2


    User Avatar
    Science Advisor
    Homework Helper

    Can you post the old example, however poorly annotated?
  4. Dec 12, 2007 #3


    User Avatar
    Science Advisor

    I assume the two points you are given are points on the parabola but what is the angle?
  5. Dec 12, 2007 #4

    Ben Niehoff

    User Avatar
    Science Advisor
    Gold Member

    One method is to treat it as a differential equation problem. All parabolas are solutions of

    [tex]\frac{d^2y}{dx^2} = 2A[/tex]

    for some constant A. Integrating, you get

    [tex]y = Ax^2 + Bx + C[/tex]

    Now, you have three parameters, and three conditions. Translate your angle into a slope, and you can write your conditions as

    [tex]y(x_1) = y_1[/tex]

    [tex]y(x_2) = y_2[/tex]

    [tex]\left \frac{dy}{dx} \right|_{x_3} = \tan \theta[/tex]

    then just solve for A, B, and C.
  6. Dec 13, 2007 #5
    I should have been a bit more specific in my post.

    I can form the two equations and the derivative equation for the constraints. The angle is also at the same point as one of the points the curve must fit, and sine the angle is zero (top of the curve), it is the same as the gradient, so no need to worry about converting.

    The bit I got stuck as was what to do with the equations, i.e. how to solve. :) Like I said, it's been a long time since I touched this. I'll have a bit more of a play and see if I can get it to work.

    Edit: I should add, once I've got this working, I'll want to add a fourth constraint that is the gradient of the other point (which will be non-zero), so need a general solution that I can scale up to a cubic equation. Thinking about it, perhaps if I try that from the beginning, it will make my old example easier to work from.

    Edit again: nope, still no luck. If it weren't for the gradients this am I correct in thinking this is a simultaneous equations problem (which I can do), but as is, it involves differential equations (which I can't). So I probably made the thread in the wrong section too.
    Last edited: Dec 13, 2007
  7. Dec 13, 2007 #6
    Well, thought I should add I got my solution by using matrices for the simultaneous differential equations. Cheers anyway. :)
  8. Dec 13, 2007 #7

    Ben Niehoff

    User Avatar
    Science Advisor
    Gold Member

    hmm...finding the constants A, B, and C is just a matter of solving simultaneous linear equations...but I suppose that's what you did if you used matrices.

    If you want a curve that conforms to four constraints in order to match a given angle at both endpoints, then you should look up "cubic spline".
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook