Subversion Repositories distributed

Rev

Rev 44 | Rev 48 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 44 Rev 45
Line 1... Line 1...
1
package de.viathinksoft.marschall.raumplan.formula;
1
package de.viathinksoft.marschall.raumplan.formula;
2
 
2
 
3
public class FormulaProbe {
3
public class FormulaProbe {
4
 
4
 
-
 
5
        private static final double PRECIOUS = 1000;
-
 
6
 
5
        /**
7
        /**
-
 
8
         * Kollissionsradius für 2D-Raum
-
 
9
         *
-
 
10
         * @param b
-
 
11
         *            Korridorverkleinerungsfaktor
-
 
12
         * @param g
-
 
13
         *            Raumverkleinerungsfaktor
-
 
14
         * @param w
-
 
15
         *            Verhältnis des initialen Korridors mit dem Ursprungsraum
-
 
16
         * @return =0 für Berührung, <0 für Abstand, > für Kollission
-
 
17
         */
-
 
18
        private static double calc_2d(double b, double g, double w) {
-
 
19
                return (3 - g) / (1 - g) - g + Math.pow(g, 2) - 4 + 2 * w
-
 
20
                                * (b / (1 - b) - b - Math.pow(b, 2) - 1);
-
 
21
        }
-
 
22
 
-
 
23
        /**
-
 
24
         * Kollissionsradius für 3D-Raum
-
 
25
         *
-
 
26
         * @param b
-
 
27
         *            Korridorverkleinerungsfaktor
-
 
28
         * @param g
-
 
29
         *            Raumverkleinerungsfaktor
-
 
30
         * @param w
-
 
31
         *            Verhältnis des initialen Korridors mit dem Ursprungsraum
-
 
32
         * @return =0 für Berührung, <0 für Abstand, > für Kollission
-
 
33
         */
-
 
34
        private static double calc_3d(double b, double g, double w) {
-
 
35
                return w * b * (1 / (1 - b) - 1 - b - Math.pow(b, 2)) + 1 / (1 - g) - 1
-
 
36
                                - g - Math.pow(g, 2) - w;
-
 
37
        }
-
 
38
 
-
 
39
        /**
-
 
40
         * Findet 2D=0 Punkte
-
 
41
         *
6
         * @param args
42
         * @param args
7
         */
43
         */
8
        public static void main(String[] args) {
44
        public static void main(String[] args) {
-
 
45
                for (int bi = 0; bi < PRECIOUS; bi++) {
-
 
46
                        for (int gi = 0; gi < PRECIOUS; gi++) {
-
 
47
                                for (int wi = 0; wi < PRECIOUS; wi++) {
-
 
48
                                        double b = (double) bi / PRECIOUS;
-
 
49
                                        double g = (double) gi / PRECIOUS;
-
 
50
                                        double w = (double) wi / PRECIOUS;
-
 
51
                                        double r2d = calc_2d(b, g, w);
9
                // TODO Auto-generated method stub
52
                                        double r3d = calc_3d(b, g, w);
10
 
53
 
-
 
54
                                        if ((Math.abs(r2d) == 0) /* || (Math.abs(r3d) == 0) */) {
-
 
55
                                                System.out.println("(b=" + b + ", g=" + g + ", w=" + w
-
 
56
                                                                + ") = " + r2d + " (2D), " + r3d + " (3D)");
-
 
57
                                        }
-
 
58
                                }
-
 
59
                        }
11
        }
60
                }
12
 
61
 
-
 
62
                System.out.println("Beendet");
-
 
63
        }
13
}
64
}