1
$\begingroup$

I have a quadratic Bézier curve.

I want to make a path that runs along that curve, whose width is 'w'. (So at any point in time along the exact center of that path, you will be also on the original Bézier curve)

How would I go about calculating two additional quadratic Bézier curves that outline the outer edges of that that path. (where any point on these edges is 'w'/2 distance from the center of the path and the original Bézier curve)?

  • 0
    The term for this is "offset curve" or "offsetting". This will improve your search results. :-) As mentioned in the answer, this is a non-trivial topic.2012-06-02

2 Answers 2

2

Just offset the control polygon of the Bezier curve by a distance of $w/2$ in each direction. As others have pointed out, this is an approximation. Position will be correct at 3 points, and the end tangent directions will be correct. Test the deviation from the true offset. If the deviation is too large, divide the original Bezier curve into two, and apply my suggested offsetting technique to the two pieces. Keep subdividing, offsetting and testing until you're happy.

To test the deviation between the approximate offset and the true one, I'd recommend an approach based on point sampling. In other words, measure the deviation at some sample points, and assume that the maximum deviation is the maximum of the deviations at these sample points. This is not really correct, of course, but it will work OK in practice. For quadratic curves, around 10 or 15 sample points is probably enough. So, take 10 points along your offset curve, measure the distance from each of them to the original curve, and compare these measured distances with the desired offset distance.

So, now, the remaining problem is how to measure the distance from a point $Q$ to a Bezier curve $C(t)$. The key is to find the "foot" of the normal from $Q$ to the curve $C$. This normal will be perpendicular to the tangent vector, so, at the "foot" point, we have:

$(Q - C(t))\cdot C'(t) = 0$

Use your favorite numerical root-finder to solve for $t$

  • 0
    Not enough space in a comment, so I added some suggestions to my previous answer.2013-02-13
1

Quadratic Bézier curves are always either pieces of parabolas or straight lines.

Unfortunally, the curve at a fixed distance from a parabola is not itself a parabola (consider, for example, the curve on the inside of the parabola at a distance that is longer than the radius of curvature at the parabola's apex), so it cannot be expressed exactly as a quadratic Bézier curve. You will have to resort to approximations.

Here is a somewhat relevant MO question.