资源简介
有关三次贝塞尔曲线拟合,拟合效果可控!本资源是来源于外国作者,所以资料的质量非常好,matlab解释很详细明了!
代码片段和文件信息
% Bezier interpolation for given four control points.
% Each control point can be in N-Dimensional vector space.
% Input:
% P0P1P2P3: four control points of bezier curve
% control points can have any number of coordinates
% t(optional arg):vector that holds paramter t values b/w 0 and 1 at which
% bezier curve is evaluated (default 101 values between 0
% and 1.)
% Output:
% Q evaluated values of bezier curves. Number of columns of Q are equal to
% number of coordinates in control point. For example for 2-D Q has two
% columns. Column 1 for x value and column 2 for y values. Similarly for
% 3-D Q will have three columns
function Q=bezierInterp(P0P1P2P3varargin)
%%% Default Values %%%
t=linspace(01101); % uniform parameterization
defaultValues = {t};
%%% Assign Valus %%%
nonemptyIdx = ~cellfun(‘isempty‘varargin);
defaultValues(nonemptyIdx) = varargin(nonemptyIdx);
[t] = deal(defaultValues{:});
% % --------------------------------
M=[-1 3 -3 1;
3 -6 3 0;
-3 3 0 0;
1 0 0 0];
for k=1:length(t)
Q(k:)=[t(k)^3 t(k)^2 t(k) 1]*M*[P0;P1;P2;P3];
end
% % Ref: Mathematical Elements of Computer Graphics by
% % David F. Rogers and J. Alan Adams (pg. 296)
% % --------------------------------
% % OR
% % Equation of Bezier Curve utilizes Horner‘s rule for efficient computation.
% % Q(t)=(-P0 + 3*(P1-P2) + P3)*t^3 + 3*(P0-2*P1+P2)*t^2 + 3*(P1-P0)*t + Px0
% c3 = -P0 + 3*(P1-P2) + P3;
% c2 = 3*(P0 - (2*P1)+P2);
% c1 = 3*(P1 - P0);
% c0 = P0;
% for k=1:length(t)
% Q(k:)=((c3*t(k)+c2)*t(k)+c1)*t(k) + c0;
% end
% % % --------------------------------
% % % Author: Dr. Murtaza Khan
% % % Email : drkhanmurtaza@gmail.com
% % % --------------------------------
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1811 2009-07-09 17:00 cubicbezierlsufit\cubicbezierlsufit\bezierInterp.m
文件 2214 2009-07-09 16:59 cubicbezierlsufit\cubicbezierlsufit\BezierInterpCPMatSegVec.m
文件 6137 2009-07-09 17:00 cubicbezierlsufit\cubicbezierlsufit\bzapproxu.m
文件 45518 2007-07-10 13:22 cubicbezierlsufit\cubicbezierlsufit\cubicbezierleastsquarefit.pdf
文件 3107 2009-07-09 17:00 cubicbezierlsufit\cubicbezierlsufit\FindBezierControlPointsND.m
文件 1622 2009-07-09 17:00 cubicbezierlsufit\cubicbezierlsufit\FindBzCP4AllSeg.m
文件 1984 2009-07-09 17:01 cubicbezierlsufit\cubicbezierlsufit\FindGivenRangeMatchedMat.m
文件 8449 2005-05-12 05:33 cubicbezierlsufit\cubicbezierlsufit\five.txt
文件 668 2009-07-09 17:01 cubicbezierlsufit\cubicbezierlsufit\getcolvector.m
文件 396 2009-07-09 17:01 cubicbezierlsufit\cubicbezierlsufit\isvec.m
文件 1826 2009-07-09 17:01 cubicbezierlsufit\cubicbezierlsufit\main.m
文件 1559 2009-07-09 17:01 cubicbezierlsufit\cubicbezierlsufit\MaxSqDistAndInd4EachSegbw2Mat.m
文件 1364 2009-07-09 17:02 cubicbezierlsufit\cubicbezierlsufit\MaxSqDistAndRowIndexbw2Mat.m
文件 929 2009-07-09 17:02 cubicbezierlsufit\cubicbezierlsufit\plot2d_bz_org_intrp_cp.m
文件 27040 2007-07-10 05:34 cubicbezierlsufit\cubicbezierlsufit\snap.PNG
文件 1337 2009-07-09 10:17 cubicbezierlsufit\license.txt
目录 0 2009-10-22 13:32 cubicbezierlsufit\cubicbezierlsufit
目录 0 2009-10-22 13:32 cubicbezierlsufit
----------- --------- ---------- ----- ----
105961 18
评论
共有 条评论