-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDecideOcto.m
100 lines (80 loc) · 1.84 KB
/
DecideOcto.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
93
94
95
96
97
98
99
100
%Quadrantes principais e seus octantes
function Octo = DecideOcto(deltax,deltay)
if deltay == 0
if deltax > 0
Octo = 9;
return
else
Octo = 13;
return
end
elseif deltax == 0
if deltay > 0
Octo = 15;
return
else
Octo = 11;
return
end
end
if abs(deltax) == abs(deltay)
if deltay < 0 && deltax > 0
Octo = 10;
return
elseif deltax < 0 && deltay < 0
Octo = 12;
return
elseif deltay > 0 && deltax < 0
Octo = 14;
return
elseif deltay > 0 && deltax > 0
Octo = 16;
return
end
end
if deltax > 0 && deltay > 0
%I
if abs(deltax)>abs(deltay)
%1
Octo = 1;
return
else
%2
Octo = 2;
return
end
elseif deltax < 0 && deltay > 0
%II
if abs(deltay)>abs(deltax)
%3
Octo = 3;
return
else
%4
Octo = 4;
return
end
elseif deltax < 0 && deltay < 0
%III
if abs(deltax)>abs(deltay)
%5
Octo = 5;
return
else
%6
Octo = 6;
return
end
elseif deltax > 0 && deltay < 0
%IV
if abs(deltay)>abs(deltax)
%7
Octo = 7;
return
else
%8
Octo = 8;
return
end
end
end