-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreduit.m
More file actions
82 lines (61 loc) · 1.68 KB
/
reduit.m
File metadata and controls
82 lines (61 loc) · 1.68 KB
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
function [start_re,goal_re,start_sp,goal_sp,D_reduit] = reduit(Start,Goal,D)
sizeD=size(D,2);
[start_sp_X,start_sp_Y]=spread(Start,sizeD);
[Goal_sp_X,Goal_sp_Y]=spread(Goal,sizeD);
for i =1:length(start_sp_Y)
if mod(start_sp_Y(i),2)==0
if mod(start_sp_Y(i)/2,2)==1
start_sp_Y(i)=start_sp_Y(i)+1;
end
if mod(start_sp_Y(i)/2,2)==0
start_sp_Y(i)=start_sp_Y(i)-1;
end
end
end
start_sp=start_sp_Y+(start_sp_X-1)*sizeD;
for i =1:length(Goal_sp_Y)
if mod(Goal_sp_Y(i),2)==0
if mod(Goal_sp_Y(i)/2,2)==1
Goal_sp_Y(i)=Goal_sp_Y(i)+1;
end
if mod(Goal_sp_Y(i)/2,2)==0
Goal_sp_Y(i)=Goal_sp_Y(i)-1;
end
end
end
goal_sp=Goal_sp_Y+(Goal_sp_X-1)*sizeD;
D_reduit=[];
for i =1:sizeD
if mod(i,2)~=0
D_reduit = [D_reduit D(:,i)];
end
end
% start_sp_ori=unique(start_sp);
% goal_sp_ori=unique(goal_sp);
for i =1:length(start_sp_Y)
if start_sp_Y(i)==1
start_sp_Y(i)=1;
else
start_sp_Y(i) = start_sp_Y(i)-(start_sp_Y(i)-1)/2;
end
end
for i =1:length(Goal_sp_Y)
if Goal_sp_Y(i)==1
Goal_sp_Y(i)=1;
else
Goal_sp_Y(i) = Goal_sp_Y(i)-(Goal_sp_Y(i)-1)/2;
end
end
sizeDre =size(D_reduit,2);
start_re=start_sp_Y+(start_sp_X-1)*sizeDre;
goal_re =Goal_sp_Y+(Goal_sp_X-1)*sizeDre;
for i=1:length(start_sp_Y)
if D_reduit(Goal_sp_X(i),Goal_sp_Y(i)) ==1 || D_reduit(start_sp_X(i),start_sp_Y(i)) ==1
disp('起点终点选择错误')
return
end
end
disp('起点终点审查通过')
% start_re_ori=unique(start_re,'stable');
% goal_re_ori=unique(goal_re,'stable');
%num=length(start_re_ori);