calculating parameters for defining subsections of quadratic bezier curves

一世执手 提交于 2019-11-30 15:13:01

Part 1

The formula for a quadratic Bezier is:

B(t) = a(1-t)2    + 2bt(1-t)   + ct2
     = a(1-2t+t2) + 2bt - 2bt2 + ct2
     = (a-2b+c)t2+2(b-a)t + a

where bold indicates a vector. With Bx(t) given, we have:

x = (ax-2bx+cx)t2+2(bx-ax)t + ax

where vx is the x component of v.

According to the quadratic formula,

     -2(bx-ax) ± 2√((bx-ax)2 - ax(ax-2bx+cx))
t = -----------------------------------------
             (2ax(ax-2bx+cx))

     ax-bx ± √(bx2 - axcx)
  = ----------------------
         ax(ax-2bx+cx)

Assuming a solution exists, plug that t back into the original equation to get the other components of B(t) at a given x.

Part 2

Rather than producing a second Bezier curve that coincides with part of the first (I don't feel like crunching symbols right now), you can simply limit the domain of your parametric parameter to a proper sub-interval of [0,1]. That is, use part 1 to find the values of t for two different values of x; call these t-values i and j. Draw B(t) for t ∈ [i,j]. Equivalently, draw B(t(j-i)+i) for t ∈ [0,1].

The t equation is wrong, you need to use eq(1)

(1) x = (ax-2bx+cx)t2+2(bx-ax)t + ax

and solve it using the the quadratic formula for the roots (2).

           -b ± √(b^2 - 4ac)
  (2)  x = -----------------
              2a

Where

a = ax-2bx+cx
b = 2(bx-ax)
c = ax - x
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!