function plot_pointcloud(pcl, stride)
%PLOT_POINTCLOUD Plot a colored pointcloud.
%   Arguments:
%       pcl: The pointcloud (nx6 matrix with rows [x y z r g b])
%               The RGB values should be normalized to 0-1
%       stride (optional): Only paint every stride-th point from the 
%               pointcloud. Useful to make the plotting faster.

if (nargin <= 1)
    stride = 1;
end

clf; 

subs=1:stride:length(pcl); 
patch(...
    repmat(pcl(subs,1),1,3)', ...
    repmat(pcl(subs,2),1,3)', ...
    repmat(pcl(subs,3),1,3)', ...
    repmat(shiftdim(pcl(subs,4:6), -1), 3, 1), ...
    'FaceColor', 'none', 'EdgeColor', 'none', ...
    'Marker', '.', 'MarkerSize', 11, ...
    'MarkerFaceColor', 'flat', 'MarkerEdgeColor', 'flat'...
);

end

