简体   繁体   中英

Split a higher order Bezier curve into many cubic curves

I need to display a bezier curve. The user chooses arbitrary points by clicking on the display area.

I implemented code to make a bezier curve with these points, but for higher order curves it doesn't work, once the order is equal the number of control points-1.

How can I split these control points to make a sequence of cubic bezier curves that represents the entire curve I want?

I'm sure you can find good resources on "drawing smooth Bezier curves" using adaptive methods , but here is what I think is a good simple approach (if rather unoptimized):

  • Generate binomial coefficients. For example, a 5th degree curve can be expressed as:

    扩展贝塞尔多项式

    The binomial coefficients are the nth row of Pascal's Triangle:

     1, 5, 10, 10, 5, 1 
  • Adaptively perform recursions at locations where successive divisions produce a significant change in the evaluated points. This happens at cusps/sharp bends where it takes many points to converge to an acceptable solution. For example:

     Note that ||B(a) - B(b)|| is notation for the length of the line between the evaluated points B(a) and B(b). Evaluate B(t) for values of t = a, b, c, d, e = 0, 0.25, 0.5, 0.75, 1. Evaluate lengths of straight line segments: ac = ||B(a) - B(c)|| ce = ||B(c) - B(e)|| Also evaluate ab, bc, cd, de. if ac - (ab + bc) > ERROR_THRESHOLD Split ab into two segments and split bc into two segments. else We have found a good enough approximation. Do the same as above for ce - (cd + de). 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM