-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathplotWaypoints.m
69 lines (59 loc) · 1.53 KB
/
plotWaypoints.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function [hf] = plotWaypoints(V, notNormalized)
%PLOTWAYPOINTS Plots a waypoints (simple plot)
% This function will plot a matrix of vertices V.
% Input parameters:
% V(n,2) - an n-by-2 matrix of vertice coordinates
% notNormalized - if true, do not plot normalized with grPlot
%
% Return variables:
% hAx - axes figure handle
%
%============= Input Validation ===============
if nargin < 1
error('No input arguments given!');
elseif nargin > 2
error('Too many arguments given!');
end
if isempty(V)
error('V is empty!');
end
[n, dimc] = size(V);
if dimc ~= 2
error('Expected V to have 2 columns');
end
useGrPlot = true;
if nargin == 2
useGrPlot = ~notNormalized
end
%% ================ Dependencies ===============
% Find all dependencies
% Add lib and class folders
addpath('lib','class');
% Add graph theory toolbox
if useGrPlot && exist('grBase') ~= 2
if exist('lib/GrTheory') ~= 7
error('Could not find the GrTheory folder.');
end
addpath('lib/GrTheory');
end
%=============== Plot waypoints ===============
[n,~] = size(V);
%dx = 0.0; dy = -0.1; % displacement so the text does not overlay the data points
%text(C(1)+dx, C(2)+dy, 'Start/End');
if (useGrPlot)
hf = grPlot(V, [], 'g', '%d', ''); % initial plot of waypoints
else
hf = gcf;
hold on;
plot(V(:,1),V(:,2),'k.','MarkerSize',20)
hold off;
end
box on;
set(gca,'xtick',[],'ytick',[])
xl = xlim;
yl = ylim;
xld = abs(xl(1) - xl(2));
yld = abs(yl(1) - yl(2));
xlim([xl(1) - xld*0.1, xl(2) + xld*0.1]);
ylim([yl(1) - yld*0.1, yl(2) + yld*0.1]);
end