joining two Bézier curves smoothly (C2 continuous)
Asked Answered
R

1

10

(Follow-up of this question.)

Given a sequence of cubic Bézier curves, how can I modify them minimally to make them join in a C2-continuous way?

Input:

  • curve P with control points P0, P1, P2, P3
  • curve Q with control points Q0, Q1, Q2, Q3
  • if it helps, you can assume that they are already C1 continuous.

Constraints:

  • C0 continuity: P3 = Q0
  • C1 continuity: P2 - P3 = Q0 - Q1
  • C2 continuity: P1 - 2*P2 + P3 = Q0 - 2*Q1 + Q2
  • modified curves as close as possible to original curves P and Q
Rennie answered 6/9, 2012 at 8:16 Comment(0)
R
3

Getting the modified curves as close as possible to the originals can have multiple interpretations, but one could consider that keeping endpoints and tangents far from the joining points constant could fit. So the points P0, P1, P3 = Q0, Q2, Q3 are constant.

We can change the origin such that P3 = Q0 = 0, enforcing C2 continuity can then be expressed as:

P1 - 2*P2 = 2*Q1 + Q2

One can expressP2=a*e^i*r and Q1=b*e^i*r in complex representations (keeping the same angle enforces C2 continuity. Compute

(P1 - Q2)/2 = c*e^i*s

Enforcing C2 continuity should be choosing r=s, and finding a combination of a and b such that a+b =c. There are infinitely many solutions, but one might use heuristics such as changing a if it is the smallest (thus producing less sensible changes).

If that's not producing sufficiently small variations, try a two-step optimisation: first change P1 and Q2 to get s closer to r, then apply the steps above.

Russom answered 26/9, 2012 at 19:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.