How to calculate the vertex of a parabola given three points

后端 未结 8 1017
故里飘歌
故里飘歌 2020-11-30 03:11

I have three X/Y points that form a parabola. I simply need to calculate what the vertex of the parabola is that goes through these three points. Preferably a quick way as I

相关标签:
8条回答
  • 2020-11-30 04:16

    Here is a code in Fortran that implements @david-z and @AZDean's solution:

    subroutine parabola_vertex(x1, y1, x2, y2, x3, y3, xv, yv)
    real(dp), intent(in) :: x1, y1, x2, y2, x3, y3
    real(dp), intent(out) :: xv, yv
    real(dp) :: denom, A, B, C
    denom = (x1 - x2) * (x1 - x3) * (x2 - x3)
    A     = (x3 * (y2 - y1) + x2 * (y1 - y3) + x1 * (y3 - y2)) / denom
    B     = (x3**2 * (y1 - y2) + x2**2 * (y3 - y1) + x1**2 * (y2 - y3)) / denom
    C     = (x2 * x3 * (x2 - x3) * y1 + x3 * x1 * (x3 - x1) * y2 + &
                x1 * x2 * (x1 - x2) * y3) / denom
    xv = -B / (2*A)
    yv = C - B**2 / (4*A)
    end subroutine
    
    0 讨论(0)
  • 2020-11-30 04:16

    This smells like homework. "Ask a Scientist" is right on. Say your 3 points are (x1, y1), (x2, y2), and (x3, y3). Then, you get three linear equations:

    | M11 M12 M13 |   | A |   | Z1 |
    | M21 M22 M23 | * | B | = | Z2 |
    | M31 M32 M33 |   | C |   | Z3 |
    

    Where M11 = x12, M12 = x1, M13 = 1, Z1 = y1, and similarly for the other two rows using (x2, y2) and (x3, y3) in place of (x1, y1).

    Solving this system of 3 equations will give you a solution for A, B, and C.

    0 讨论(0)
提交回复
热议问题