-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathplotWaypointGrid.m
92 lines (72 loc) · 1.83 KB
/
plotWaypointGrid.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
function [fig] = plotWaypointGrid(hAx, V, options)
% PLOTWAYPOINTGRID Plot a grid around the waypoints in V
% =================== Check Arguments ========================
if nargin < 1
error('No input arguments given!');
elseif nargin > 3
error('Too many arguments given!');
end
if isempty(hAx)
error('hAx not given!');
end
if isempty(V)
error('V is empty!');
end
[n, ~] = size(V);
% ======================== Setup ============================
md = normalizationCoeff(V);
%V = V./md;
xv = V(:,1);
yv = V(:,2);
w = options.SensorWidth;
wd = w/md;
%Find the bounding rectangle
N = 1/w;
lower_x = min(xv);
higher_x = max(xv);
lower_y = min(yv);
higher_y = max(yv);
%Create a grid of points within the bounding rectangle
inc_x = 1/N;
inc_y = 1/N;
interval_x = lower_x:inc_x:higher_x + w;
interval_y = lower_y:inc_y:higher_y + w;
%meshgrid(interval_x, interval_y)
[X, Y] = meshgrid(interval_x, interval_y);
% Transform into grid
%[1 0 -w; 0
%X = X*2 + options.SensorWidth/2;
hold on;
X=X./md
Y=Y./md
plot(X-wd/2, Y-wd/2, ':k');
plot(Y-wd/2, X-wd/2, ':k');
%plot(bigGridX, bigGridY);
%set(axes_handle,'XGrid','on')
%set(axes_handle,'XGrid','on')
hold off;
% ====================== Plot Grid =========================
end % function plotWaypointGrid
function [X,Y] = expandPoints(X,Y,w)
% Rt = [1 0 -w/2;
% 0 1 -w/w;
% 0 0 1];
% Rs = [w/2 0 0;
% 0 w/2 0;
% 0 0 1];
Rt = [1 0 0;
0 1 0;
-w/2 w/2 1];
Rs = [w/2 0 0;
0 w/2 0;
0 0 1];
n = length(X);
tform_trans = affine2d(Rt);
tform_scale = affine2d(Rs);
for i = 1:n
Vhat = [X(i), Y(i), 1];
Vprime = Rt*Vhat';
X(i) = Vprime(1)/Vprime(3);
Y(i) = Vprime(2)/Vprime(3);
end
end