Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So I assume that the endpoints are fixed, and then you have a number of (x,y) sample points that you want to fit with a cubic Bezier.</p> <p>The number of sample points that you have will determine what approach to take. Let's look through a few cases:</p> <p><strong>2 points</strong></p> <p>2 sample points is the simplest case. That gives you a total of 4 points, if you count the end points. This is the number of CVs in a cubic Bezier. To solve this, you need a parameter (t) value for both of the sample points. Then you have a system of 2 equations and 2 points that you need to solve, where the equation is the parametric equation of a Bezier curve at the t values you've chosen. </p> <p>The t values can be whatever you like, but you will get better results by using either 1/3 and 2/3, or looking at relative distances, or relative distances along a baseline, depending on your data.</p> <p><strong>1 point</strong></p> <p>This is similar to 2 points, except that you have insufficient information to uniquely determine all your degrees of freedom. What I would suggest is to fit a quadratic Bezier, and then degree elevate. I wrote up a detailed example of quadratic fitting in <a href="https://stackoverflow.com/questions/18476308/non-parametric-quadratic-bezier-curve-through-3-points-in-2d-in-r/18485522#18485522">this question</a>.</p> <p><strong>More than 2 points</strong></p> <p>In this case, there isn't a unique solution. I have used least-squares approximation with good results. The steps are:</p> <ul> <li>Pick t values for each sample</li> <li>Build your system of equations as a matrix</li> <li>Optionally add fairing or some other smoothing function</li> <li>Solve the matrix with a least-squares solver</li> </ul> <p>There is a good description of these steps in this <a href="http://tom.cs.byu.edu/~557/text/cagd.pdf" rel="nofollow noreferrer">free cagd textbook</a>, chapter 11. It talks about fitting b-splines, but a cubic bezier is a type of b-spline (knot vector is 0,0,0,1,1,1 and has 4 points).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload