%% Buffer Line Segments
% Create buffer regions surrounding line segments.
% Create a matrix of 2-D points, and compute a polyshape object that buffers the line segments connecting the points.

P = [0 0; 1 1; 2 1];
polyout1 = polybuffer(P,'lines',0.25);
plot(P(:,1),P(:,2),'r.','MarkerSize',10)
hold on
plot(polyout1)
axis equal
hold off

% By default, polybuffer rounds out the joints that connect line segments. You can control the shape of joints by using the 'JointType' name-value pair. For example, use the value 'miter' to preserve the angle connecting the two line segments.

figure
polyout2 = polybuffer(P,'lines',0.25,'JointType','miter');
plot(P(:,1),P(:,2),'r.','MarkerSize',10)
hold on
plot(polyout2)
axis equal

% Copyright 2012 The MathWorks, Inc.