-
Notifications
You must be signed in to change notification settings - Fork 0
/
getXYPath.m
33 lines (26 loc) · 859 Bytes
/
getXYPath.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
function [ weight ] = getXYPath(currX, currY, destX, destY, boxes)
weight = 0;
blocked = 0;
% do this until Y values are same
while( currX ~= destX)
% go right or left
if ( currX < destX)
currX = currX + 1;
else
currX = currX - 1;
end
% check if a specific point exist in the polygon
blocked = isPathBlocked( boxes, currX, currY);
% if path is blocked, break out of loop
if ( blocked)
weight = 0;
break;
end
% if path not blocked, increment weight
weight = weight + 1;
end
% x-coordinates same, now go up/down
if ( blocked == 0)
weight = goUpOrDown( currX, currY, destX, destY, boxes, weight);
end
end