Чтобы выполнить расчеты, я написал этот код:
Код: Выделить всё
List YPoint = new java.util.ArrayList(Arrays.asList(A.y, B.y, C.y, D.y, E.y, F.y, G.y, K.y, Q.y, L.y, M.y, N.y));
List YUpper = new java.util.ArrayList(Arrays.asList());
int Classified = 0;
int Highest = 0;
while(Classified != 6){
Highest = Collections.min(YPoint);
YPoint.remove(Integer.valueOf(Highest));
YUpper.add(Integer.valueOf(Highest));
Classified++;
}
android.graphics.Point Highest1 = new android.graphics.Point();
android.graphics.Point Highest2 = new android.graphics.Point();
android.graphics.Point Highest3 = new android.graphics.Point();
android.graphics.Point Highest4 = new android.graphics.Point();
android.graphics.Point Highest5 = new android.graphics.Point();
android.graphics.Point Highest6 = new android.graphics.Point();
boolean notdone = false;
if(YUpper.contains(A.y)){
if(Highest1.x == 0 && !notdone){Highest1 = A; notdone = true;}
if(Highest2.x == 0 && !notdone){Highest2 = A; notdone = true;}
if(Highest3.x == 0 && !notdone){Highest3 = A; notdone = true;}
if(Highest4.x == 0 && !notdone){Highest4 = A; notdone = true;}
if(Highest5.x == 0 && !notdone){Highest5 = A; notdone = true;}
if(Highest6.x == 0 && !notdone){Highest6 = A; notdone = true;}
notdone = false;
}
if(YUpper.contains(B.y)){
if(Highest1.x == 0 && !notdone){Highest1 = B; notdone = true;}
if(Highest2.x == 0 && !notdone){Highest2 = B; notdone = true;}
if(Highest3.x == 0 && !notdone){Highest3 = B; notdone = true;}
if(Highest4.x == 0 && !notdone){Highest4 = B; notdone = true;}
if(Highest5.x == 0 && !notdone){Highest5 = B; notdone = true;}
if(Highest6.x == 0 && !notdone){Highest6 = B; notdone = true;}
notdone = false;
}
if(YUpper.contains(C.y)){
if(Highest1.x == 0 && !notdone){Highest1 = C; notdone = true;}
if(Highest2.x == 0 && !notdone){Highest2 = C; notdone = true;}
if(Highest3.x == 0 && !notdone){Highest3 = C; notdone = true;}
if(Highest4.x == 0 && !notdone){Highest4 = C; notdone = true;}
if(Highest5.x == 0 && !notdone){Highest5 = C; notdone = true;}
if(Highest6.x == 0 && !notdone){Highest6 = C; notdone = true;}
notdone = false;
}
if(YUpper.contains(E.y)){
if(Highest1.x == 0 && !notdone){Highest1 = E; notdone = true;}
if(Highest2.x == 0 && !notdone){Highest2 = E; notdone = true;}
if(Highest3.x == 0 && !notdone){Highest3 = E; notdone = true;}
if(Highest4.x == 0 && !notdone){Highest4 = E; notdone = true;}
if(Highest5.x == 0 && !notdone){Highest5 = E; notdone = true;}
if(Highest6.x == 0 && !notdone){Highest6 = E; notdone = true;}
notdone = false;
}
if(YUpper.contains(D.y)){
if(Highest1.x == 0 && !notdone){Highest1 = D; notdone = true;}
if(Highest2.x == 0 && !notdone){Highest2 = D; notdone = true;}
if(Highest3.x == 0 && !notdone){Highest3 = D; notdone = true;}
if(Highest4.x == 0 && !notdone){Highest4 = D; notdone = true;}
if(Highest5.x == 0 && !notdone){Highest5 = D; notdone = true;}
if(Highest6.x == 0 && !notdone){Highest6 = D; notdone = true;}
notdone = false;
}
if(YUpper.contains(F.y)){
if(Highest1.x == 0 && !notdone){Highest1 = F; notdone = true;}
if(Highest2.x == 0 && !notdone){Highest2 = F; notdone = true;}
if(Highest3.x == 0 && !notdone){Highest3 = F; notdone = true;}
if(Highest4.x == 0 && !notdone){Highest4 = F; notdone = true;}
if(Highest5.x == 0 && !notdone){Highest5 = F; notdone = true;}
if(Highest6.x == 0 && !notdone){Highest6 = F; notdone = true;}
notdone = false;
}
if(YUpper.contains(G.y)){
if(Highest1.x == 0 && !notdone){Highest1 = G; notdone = true;}
if(Highest2.x == 0 && !notdone){Highest2 = G; notdone = true;}
if(Highest3.x == 0 && !notdone){Highest3 = G; notdone = true;}
if(Highest4.x == 0 && !notdone){Highest4 = G; notdone = true;}
if(Highest5.x == 0 && !notdone){Highest5 = G; notdone = true;}
if(Highest6.x == 0 && !notdone){Highest6 = G; notdone = true;}
notdone = false;
}
if(YUpper.contains(Q.y)){
if(Highest1.x == 0 && !notdone){Highest1 = Q; notdone = true;}
if(Highest2.x == 0 && !notdone){Highest2 = Q; notdone = true;}
if(Highest3.x == 0 && !notdone){Highest3 = Q; notdone = true;}
if(Highest4.x == 0 && !notdone){Highest4 = Q; notdone = true;}
if(Highest5.x == 0 && !notdone){Highest5 = Q; notdone = true;}
if(Highest6.x == 0 && !notdone){Highest6 = Q; notdone = true;}
notdone = false;
}
if(YUpper.contains(K.y)){
if(Highest1.x == 0 && !notdone){Highest1 = K; notdone = true;}
if(Highest2.x == 0 && !notdone){Highest2 = K; notdone = true;}
if(Highest3.x == 0 && !notdone){Highest3 = K; notdone = true;}
if(Highest4.x == 0 && !notdone){Highest4 = K; notdone = true;}
if(Highest5.x == 0 && !notdone){Highest5 = K; notdone = true;}
if(Highest6.x == 0 && !notdone){Highest6 = K; notdone = true;}
notdone = false;
}
if(YUpper.contains(N.y)){
if(Highest1.x == 0 && !notdone){Highest1 = N; notdone = true;}
if(Highest2.x == 0 && !notdone){Highest2 = N; notdone = true;}
if(Highest3.x == 0 && !notdone){Highest3 = N; notdone = true;}
if(Highest4.x == 0 && !notdone){Highest4 = N; notdone = true;}
if(Highest5.x == 0 && !notdone){Highest5 = N; notdone = true;}
if(Highest6.x == 0 && !notdone){Highest6 = N; notdone = true;}
notdone = false;
}
if(YUpper.contains(L.y)){
if(Highest1.x == 0 && !notdone){Highest1 = L; notdone = true;}
if(Highest2.x == 0 && !notdone){Highest2 = L; notdone = true;}
if(Highest3.x == 0 && !notdone){Highest3 = L; notdone = true;}
if(Highest4.x == 0 && !notdone){Highest4 = L; notdone = true;}
if(Highest5.x == 0 && !notdone){Highest5 = L; notdone = true;}
if(Highest6.x == 0 && !notdone){Highest6 = L; notdone = true;}
notdone = false;
}
if(YUpper.contains(M.y)){
if(Highest1.x == 0 && !notdone){Highest1 = M; notdone = true;}
if(Highest2.x == 0 && !notdone){Highest2 = M; notdone = true;}
if(Highest3.x == 0 && !notdone){Highest3 = M; notdone = true;}
if(Highest4.x == 0 && !notdone){Highest4 = M; notdone = true;}
if(Highest5.x == 0 && !notdone){Highest5 = M; notdone = true;}
if(Highest6.x == 0 && !notdone){Highest6 = M; notdone = true;}
notdone = false;
}
YPoint.remove(Integer.valueOf(Highest1.y));
YPoint.remove(Integer.valueOf(Highest2.y));
YPoint.remove(Integer.valueOf(Highest3.y));
YPoint.remove(Integer.valueOf(Highest4.y));
YPoint.remove(Integer.valueOf(Highest5.y));
YPoint.remove(Integer.valueOf(Highest6.y));
< /code>
Проще говоря, мой код следует за этим алгоритмом: < /p>
[*] Составьте список из 12 баллов y < /code> координаты
[*] Получить 6 int Найдите точки, которые Соответствуют этим 6 INT от 2 < /li>
Сделайте новые 6 баллов и устанавливают их координаты на точки из 3 - I дубликатов точек, чтобы я мог использовать их в дальнейших расчетах. < /li>
< /ol>
Этот код выше работает, но он огромный и грязный. Есть ли хорошая и чистая альтернатива для этого?
Подробнее здесь: https://stackoverflow.com/questions/316 ... ing-points
Мобильная версия