Code covered by the BSD License  

Highlights from
Bezier Curve Function

1.0

1.0 | 2 ratings Rate this file 14 Downloads (last 30 days) File Size: 1.37 KB File ID: #34902
image thumbnail

Bezier Curve Function

by Prakash Manandhar

 

02 Feb 2012

Vectorized function to calculate Bezier Curve

| Watch this File

File Information
Description

This function constructs a Bezier curve from given control points. P is a vector of control points. N is the number of points to calculate.

Example:

P = [0 0; 1 1; 2 5; 5 -1];
x = (0:0.0001:5);
y = BezierCurve(length(x), P);
plot(x, y, P(:, 1), P(:, 2), 'x-', 'LineWidth', 2); set(gca, 'FontSize', 16)

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Bezier Curve Plotter

MATLAB release MATLAB 7.11 (2010b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
16 Feb 2012 Joey

I don't understand the math well enough to pick out exactly what's wrong, but the curve that this code gives for certain sets of points is definitely not right.

Try this and you'll see:
P = [0 2; 4.38 6.38; 5.32 5.32; 9.7 9.7];
x = (0:0.01:9.7);
y = BezierCurve(length(x), P);
plot(x, y, P(:, 1), P(:, 2), 'x-', 'LineWidth', 2); set(gca, 'FontSize', 16)

http://img685.imageshack.us/img685/9228/badcurve.jpg

16 Feb 2012 Joey  
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
mathematics Prakash Manandhar 03 Feb 2012 11:53:09
graphics Prakash Manandhar 03 Feb 2012 11:53:09
curve generation Prakash Manandhar 03 Feb 2012 11:53:10

Contact us at files@mathworks.com