59 bool movedRight = false; |
59 bool movedRight = false; |
60 |
60 |
61 //De la position p1 à pn, on suit l'algorithme. |
61 //De la position p1 à pn, on suit l'algorithme. |
62 for (int i = localHistory.Count - indexesToCheck + 1; i < localHistory.Count; i++) |
62 for (int i = localHistory.Count - indexesToCheck + 1; i < localHistory.Count; i++) |
63 { |
63 { |
64 /*if (localHistory[i][(int)JointType.HandRight].Position.Y < localHistory[i][(int)JointType.ElbowRight].Position.Y + refDistance) |
64 /*if (localHistory[i][(int)JointType.HandRight].Position.Y + refDistance / 2 > localHistory[i][(int)JointType.ElbowRight].Position.Y) |
|
65 debug.onR0(false); |
|
66 else |
65 debug.onR0(true); |
67 debug.onR0(true); |
|
68 if (localHistory[i][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.HipCenter].Position.Y) |
|
69 debug.onR1(false); |
66 else |
70 else |
67 debug.onR0(false); |
|
68 if (localHistory[i][(int)JointType.HandRight].Position.Y < localHistory[i][(int)JointType.HipCenter].Position.Y) |
|
69 debug.onR1(true); |
71 debug.onR1(true); |
|
72 if (localHistory[i][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.WristRight].Position.Y) |
|
73 debug.onR2(false); |
70 else |
74 else |
71 debug.onR1(false); |
|
72 if (localHistory[i][(int)JointType.HandRight].Position.Y < localHistory[i][(int)JointType.WristRight].Position.Y + refDistance / 4) |
|
73 debug.onR2(true); |
75 debug.onR2(true); |
|
76 if (Math.Abs(localHistory[i][(int)JointType.HandRight].Position.Z - localHistory[i][(int)JointType.Head].Position.Z) > 0.20) |
|
77 debug.onR3(false); |
74 else |
78 else |
75 debug.onR2(false);*/ |
79 debug.onR3(true);*/ |
76 //Si la position Y de la main droite est plus haute que le coude + la distance de référence |
80 //Si la position Y de la main droite est plus haute que le coude + la distance de référence |
77 //OU si la position Y de la main droite est plus basse que la hanche |
81 //OU si la position Y de la main droite est plus basse que la hanche |
78 //OU si la position Y de la main droite est plus haute que le poignet + le quart de la distance de référence. |
82 //OU si la position Y de la main droite est plus haute que le poignet + le quart de la distance de référence |
|
83 //OU si la distance Y de la main à la tete est plus grande que la distance de référence |
|
84 //OU si la distance Z de la main à la tete est plus grande que 20 cm. |
79 //Alors la main en question ne fait pas de Wave. |
85 //Alors la main en question ne fait pas de Wave. |
80 if (localHistory[i][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.ElbowRight].Position.Y + refDistance || |
86 if (localHistory[i][(int)JointType.HandRight].Position.Y + refDistance / 2 > localHistory[i][(int)JointType.ElbowRight].Position.Y || |
81 localHistory[i][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.HipCenter].Position.Y || |
87 localHistory[i][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.HipCenter].Position.Y || |
82 localHistory[i][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.WristRight].Position.Y + refDistance / 4) |
88 localHistory[i][(int)JointType.HandRight].Position.Y > localHistory[i][(int)JointType.WristRight].Position.Y || |
|
89 Math.Abs(localHistory[i][(int)JointType.HandRight].Position.Z - localHistory[i][(int)JointType.Head].Position.Z) > 0.20) |
83 return false; |
90 return false; |
84 |
91 |
85 //On vérifie si la main à bougé vers la droite. |
92 //On vérifie si la main à bougé vers la droite. |
86 |
93 |
87 if (localHistory[i][(int)JointType.HandRight].Position.X >= startPosX + refDistance / 2 && !movedRight) |
94 if (localHistory[i][(int)JointType.HandRight].Position.X >= startPosX + refDistance / 2 && !movedRight) |
88 movedRight = true; |
95 movedRight = true; |
89 |
96 |
90 //Si la main a bougé vers la droite, on regarde si elle est retournée à sa position initiale. |
97 //Si la main a bougé vers la droite, on regarde si elle est retournée à sa position initiale. |
91 if (movedRight && localHistory[i][(int)JointType.HandRight].Position.X <= startPosX) |
98 if (movedRight && Math.Abs(localHistory[i][(int)JointType.HandRight].Position.X - startPosX) <= refDistance) |
92 { |
99 { |
93 history.Clear(); |
100 history.Clear(); |
94 return true; |
101 return true; |
95 } |
102 } |
96 } |
103 } |