Sign in to follow this  

Cubic Bezier curves

This topic is 3100 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Here is the MATLAB code that I wrote to generate a cubic bezier curve given 4 control points. It doesn't interpolate between two endpoints. Can you tell what is wrong with it? --------------------- clc clear p0 = [ 0; 0 ]; p1 = [ 5; 10 ]; p2 = [ 10; 15 ]; p3 = [ 20; -10 ]; G = [ p0 p1 p2 p3 ]; B = [ 1 -3 3 -1; 0 3 -6 -3; 0 0 3 -3; 0 0 0 1 ]; i = 1; for t = 0:0.05:1 T(1,i) = 1; T(2,i) = t; T(3,i) = t^2; T(4,i) = t^3; i = i + 1; end curve = G*B*T; grid on hold on plot( curve(1,:), curve(2, :) ); plot( G(1,:), G(2,:), '--rs', 'MarkerSize', 10 ); hold off --------------------- Image Hosted by ImageShack.us<br/>

Share this post


Link to post
Share on other sites
Hi Dynx, I think you have an error in your B matrix(the coefficient for P1*t^3 should be +3, not -3). Try this
B = [ 1 -3 3 -1; 0 3 -6 3; 0 0 3 -3; 0 0 0 1 ];

Share this post


Link to post
Share on other sites

This topic is 3100 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this