Reputation: 3317
The more control points on a Bézier curve the less near any given control point the curve reaches.
For example a 2 point (linier) curve reaches both control points. A 3 point (quadratic) curve forms an arc, between the three points, this is ideal for me, it's not following the line exactly, as then it wouldn't be a curve, there is however a strong visual relationship between the control points and the line.
With a 4 point (cubic) curve with control points in a zig-zag however the resultant line is much more straight. Extended to use 100 control points in a zig-zag the curve is almost completly straight.
To stay with the zig-zag example, one way to form the curve I'm looking for, which in this case would look like a less aggressively smoothed zig-zag than an 100 control point Bézier curve would produce, would be to break the shape into many small 3 point Bézier curves, interpolating between them at the ends.
Is there C#, pseudo-code or even just more information in a simple form available to do this more complicated Bézier curve related task?
Upvotes: 2
Views: 1163
Reputation: 114481
Something very easy to implement is to build the curve using quadratic bezier arcs
You basically use midpoints between source vertices as start/stop of each arc and source vertices as the control point for the arc. This choice guarantees continuity of the tangent and leaves a lot of control on the curve shape.
Also you can easily get sharp corners by using two consecutive source vertices with the same coordinates.
Upvotes: 6