-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrangetest.m
More file actions
52 lines (38 loc) · 810 Bytes
/
rangetest.m
File metadata and controls
52 lines (38 loc) · 810 Bytes
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
function [ test, uvt ] = rangetest( uvt,ui,vi,u2i,v2i,tol )
% test if paramaters does not leave current patch, otherwise it is returned
% back
test = 0;
du = [uvt(1)-ui(1), ui(2)- uvt(1)];
dv = [uvt(2)-vi(1), vi(2)- uvt(2)];
if length(v2i) == 1
d2p = [uvt(3)-u2i(1), u2i(2)- uvt(3)];
pi = u2i;
end
if length(u2i) == 1
d2p = [uvt(3)-v2i(1), v2i(2)- uvt(3)];
pi = v2i;
end
%dv = [uvt(2)-vi(1), vi(2)- uvt(2)];
for i =1:2
if (du(i) < -tol)
uvt(1) = ui(i);
end
end
for i =1:2
if (dv(i) < -tol)
uvt(2) = vi(i);
end
end
for i =1:2
if (d2p(i) < -tol)
uvt(3) = pi(i);
end
end
if (uvt(1)>=ui(1)) && (uvt(1)<=ui(2))
if (uvt(2)>=vi(1)) && (uvt(2)<=vi(2))
if ((uvt(3)>=pi(1)) && (uvt(3)<=pi(2)))
test = 1;
end
end
end
end