Nearest point on cubic bezier curve to a given point

前端 未结 1 597

I have a cubic-Bezier curve defined as A, B, C, D. Where A is the start, B and C are control points, and D is the end. I understand how to find the position at any value t

1条回答
  •  说谎
    说谎 (楼主)
    2021-01-20 16:39

    As cmaster says, this leads to the solution of a fifth degree polynomial to find the minimum of a sixth degree polynomial

    It does not really matter if it is 2D or 3D. The function to minimize is the sixth degree polynomial

    f(t)=0.5*dot(p(t)-X,p(t)-X) such that 0<=t<=1
    

    where X is the given point and p(t) the polynomial curve, and dot denotes the euclidean scalar product. Minimization can be achieved by finding all of the roots of the derivative

    f'(t)=dot(p'(t), p(t)-X)
    

    inside the interval and comparing the function values of the roots and at the end points of the interval.

    There also exist minimization methods that do not use derivatives, mainly intended for functions that are more complicated than polynomials. See for instance chapter 5 in

    Brent, R. P. (1973), Algorithms for Minimization without Derivatives, Englewood Cliffs, NJ: Prentice-Hall, ISBN 0-13-022335-2

    (which book nevertheless contains extensive sections on derivatives and Taylor polynomials). The method or its principal idea can also be found in "Numerical recipes" as "golden section search".

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