Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Curve fitting with boundary conditions #367

Open
victorsalit opened this issue Jul 11, 2022 · 1 comment
Open

Curve fitting with boundary conditions #367

victorsalit opened this issue Jul 11, 2022 · 1 comment

Comments

@victorsalit
Copy link

Hi Pomax,

first of all many thanks for your time and efforts!
I would like to ask about how to implement the known end slopes boundary conditions into the curve fitting using the least squares.
Suppose I have a collection of points and I would like to best fit a Bezier curve of a given degree to these points. Suppose, also, I would like to treat the first and the last point as actual first and last control points. Starting from the error definition in matrix notation
E(C) = (P - TMC)^T (P - TMC)
d(E(C))/dC = -2(TM)^T (P - TMC) <--- your equation lacks M^T
after rearrangement and abbreviating TM as b, we get
b^T bC = b^T P.
Let's define b^T b => B and b^T P => A, such that we now have
BC = A.
If C(1) and C(end) are known, we get
B(2:end-1, 2:end-1)C(2:end-1) = A(2:end-1) - C(1)B(2:end-1,1) - C(end)B(2:end-1,end)
and finally
C(2:end-1) = B(2:end-1, 2:end-1)C(2:end-1)^-1 [A(2:end-1) - C(1)B(:,1) - C(end)B(:,end)]
This works like a charm. However, I don't understand how to derive/implement the slope conditions (let say in the form of unit tangents) at the first and last points...

Would really appreciate your thoughts on this.
Victor

@victorsalit
Copy link
Author

Any thought/comments?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant