Path: utzoo!attcan!uunet!ns-mx!iowasp.physics.uiowa.edu!maverick.ksu.ksu.edu!rutgers!usc!samsung!umich!umeecs!zip!spencer From: spencer@eecs.umich.edu (Spencer W. Thomas) Newsgroups: comp.graphics Subject: Re: Shrinking Bezier curves Message-ID: Date: 27 Jul 90 12:36:20 GMT References: <1990Jul27.063052.9708@allgfx.agi.oz> Sender: news@zip.eecs.umich.edu Organization: University of Michigan EECS Dept Lines: 50 In-reply-to: pm@allgfx.agi.oz's message of 27 Jul 90 06:30:52 GMT Question: offsetting Bezier curves. Simple answer: Can't be done. The result is not a Bezier curve. Simple demonstration: start with a parabola. Pick a "large enough" offset. The resulting offset curve has a loop in it. This is certainly not a quadratic curve any longer (you can't put a loop in a quadratic). In fact, it's not a polynomial. More justification: The offset is a normal vector to the curve, of constant length. To get the "constant length" part, you need to take a square root: offset_vec = const * normal_vec / length(normal_vec) where normal_vec = d/dt ( curve ) and length(vec) = sqrt(vec_x^2 + vec_y^2 + vec_z^2); d/dt is a linear operator which, when applied to a polynomial (Bezier) curve, results in a polynomial (Bezier) curve. sqrt is a non-linear operator, so the result is not polynomial (or Bezier), unless you are really lucky. A possible solution: subdivide the curve into lots of little almost-straight pieces, then compute an approximate offset curve for each. This computation is not trivial if you want to maintain some (i.e., tangent) continuity, but can be done. I'll sketch a possible solution (maybe someone else out there can come up with a better one). For now, assume the curve is cubic (so there are four control points); the solution is more complex (i.e., more than I want to think about right now) for higher degrees. For each Bezier (defined by p0, p1, p2, p3): Offset the endpoints according to the above equation, resulting in p0', p3'. d = distance( p0, p3 ); d' = distance( p0', p3' ); tan0 = p1 - p0; tan1 = p2 - p3; p1' = p0' + (d'/d) * tan0; p2' = p3' + (d'/d) * tan1; This preserves tangent continuity, but fails in the case where the initial offset operation reverses p0 and p3 (i.e., where a loop would be introduced). It can be fixed, but I'll leave that as "an exercise for the reader". =Spencer W. Thomas EECS Dept, U of Michigan, Ann Arbor, MI 48109 spencer@eecs.umich.edu 313-936-2616 (8-6 E[SD]T M-F) -- =Spencer W. Thomas EECS Dept, U of Michigan, Ann Arbor, MI 48109 spencer@eecs.umich.edu 313-936-2616 (8-6 E[SD]T M-F)