Question

I'm looking for a simple algorithm for line curving (much like fireworks freeform tool). In my C++ program, a line is a set of ordered points, each point is of (x,y) form. Assume I have straight line of 5 (just for simplicity) ordered points (the line isn't necessarily parallel to any axis). I pinch the 3rd point and drag it up. I'm expecting to have a new, gaussian-like, curved line. It doesn't really matter how I implement the "Points" and "Lines", but keep in mind I should add more points to the new expected line so it'll be curved, refined and flowing (and not with line breaks). I thought of using a gaussian function but I need the ability of moving the curved part (see picture below).

Thanks in advance!

Figures 1 - 3 describe the process of "Pinching and curving"

Was it helpful?

Solution

You need a B-spline or a Bezier curve to approximate your shape.

There is a nice interactive demo of Bezier splines so you can play with to see the effect. A sample screenshot below:

bezier

Depending on your OS and development environment, there are probably already a number of tools or APIs available.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top