%PLOTBEZIER Plot Bezier Curve % Plot Bezure curve, Bezure points and velocity. % % Syntax: plotbezier(dt, CP) % % Inputs: % dt - the parameter increment size that you want points along the % curve to be plotted at. Remember the parameter varies from % 0 - 1 along the curve, dt = .01 will give 100 points % CP - a nxm vector of n control points in 1, 2 or 3-space % % Outputs: % - a plot of the characteristic polygon % - a plot of the curve as a series of equi-spaced points in terms of % the curve parameter t. % - a separate plot of velocity variation as a function of the parameter t % % Other m-files required: bezier.m % % See also: BEZIER % Author: Travis Hydzik % Last revision: 20 October 2004 function plotbezier(dt, CP) v = []; p = CP(1,:); x = p; for t = dt:dt:1 pNew = bezier(t, CP); v = [v norm(pNew - p)]; p = pNew; x = [x; p]; end [n, m] = size(x); clf subplot(1,2,1) if m == 1 line(CP(:,1), zeros(1,m), 'Marker', '+', 'MarkerEdgeColor','b' ); hold on line(x(:,1), zeros(1,m), 'LineStyle','none', 'Marker', '.', 'MarkerEdgeColor','r' ); elseif m == 2 line(CP(:,1),CP(:,2), 'Marker', '+', 'MarkerEdgeColor','b' ); hold on line(x(:,1),x(:,2),'LineStyle','none', 'Marker', '.', 'MarkerEdgeColor','r' ); elseif m == 3 line(CP(:,1),CP(:,2),CP(:,3), 'Marker', '+', 'MarkerEdgeColor','b' ); hold on line(x(:,1),x(:,2),x(:,3),'LineStyle','none', 'Marker', '.', 'MarkerEdgeColor','r' ); cosmetics(3) end hold off subplot(1,2,2) plot(v)