-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculate_indicators.m
53 lines (48 loc) · 1.17 KB
/
calculate_indicators.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
% 计算指标的函数
function [N_g, N_t, N_d, N_s] = calculate_indicators(Z_h, S, T, C, D, A_I_X, A_I_Y, A_I_Z)
n = length(Z_h);
N_g = 0;
N_t = 0;
N_d = 0;
N_s = 0;
% 计算几何干涉次数 N_g
for i = 1:n-1
switch D(i) % 使用装配方向
case "+X"
A_I = A_I_X;
case "-X"
A_I = A_I_X';
case "+Y"
A_I = A_I_Y;
case "-Y"
A_I = A_I_Y';
case "+Z"
A_I = A_I_Z;
case "-Z"
A_I = A_I_Z';
otherwise
error('未知的装配方向');
end
if A_I(Z_h(i), Z_h(i+1)) == 1
N_g = N_g + 1;
end
end
% 计算工具改变次数 N_t
for i = 1:n-1
if T(Z_h(i)) ~= T(Z_h(i+1))
N_t = N_t + 1;
end
end
% 计算方向改变次数 N_d
for i = 1:n-1
if D(i) ~= D(i+1)
N_d = N_d + 1;
end
end
% 计算不稳定操作次数 N_s
for i = 2:n
if C(Z_h(i), Z_h(i-1)) ~= 1 && S(Z_h(i), Z_h(i-1)) ~= 1
N_s = N_s + 1;
end
end
end