• API
• FAQ
• Tools
• Trends
• Archive
daily pastebin goal
19%
SHARE
TWEET

# Untitled

a guest May 19th, 2017 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import java.util.ArrayList;
2.
3. public class UpdaterLoop {
4.
5.     MainFrame frame;
6.
7.     public UpdaterLoop(MainFrame frame){
8.         this.frame = frame;
9.     }
10.
11.     public int square(Point a, Point b, Point c){
12.         return Math.abs(a.vectorProduct(b) + b.vectorProduct(c) + c.vectorProduct(a));
13.     }
14.
15.
16.     public int check(Point p, Point a, Point b, Point c){
17.         int spab = square(p, a, b);
18.         int spbc = square(p, b, c);
19.         int spac = square(p, a, c);
20.         int sabc = square(a, b, c);
21.         if (spab + spbc + spac == sabc && spab > 0 && spbc > 0 && spac > 0)
22.             return 1;
23.         else
24.             return 0;
25.     }
26.
27.     public static ArrayList<Point> triangle = new ArrayList<>();
28.     public static int maxi = -1;
29.
30.     public ArrayList<Point> update(){
31.         int sz = frame.allPoints.size();
32.         for (int i = 0; i < sz; i++){
33.             for (int j = 0; j < i; j++){
34.                 for (int l = 0; l < j; l++) {
35.                     int cnt = 0;
36.                     for (int k = 0; k < frame.allPoints.size(); k++)
37.                         cnt += check(frame.allPoints.get(k), frame.allPoints.get(i), frame.allPoints.get(j), frame.allPoints.get(l));
38.                     if (cnt > maxi && square(frame.allPoints.get(i), frame.allPoints.get(j), frame.allPoints.get(l)) > 0) {
39.                         maxi = cnt;
40.                         triangle.clear();