Created
February 21, 2013 10:40
-
-
Save joriki/5003827 to your computer and use it in GitHub Desktop.
Find the infimum and supremum of the sum of the dihedral angles in a tetrahedron; see http://math.stackexchange.com/questions/310005.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Question310005 { | |
final static int pairs [] [] [] = {{{0,1},{2,3}},{{0,2},{1,3}},{{0,3},{1,2}}}; | |
public static void main (String [] args) { | |
int ntrials = Integer.parseInt (args [0]); | |
double min = Double.MAX_VALUE; | |
double max = 0; | |
double [] [] x = new double [4] [3]; | |
double [] e = new double [3]; | |
double [] [] t = new double [2] [3]; | |
double [] n = new double [2]; | |
double [] s = new double [2]; | |
for (int m = 0;m < ntrials;m++) { | |
for (int i = 0;i < 4;i++) | |
for (int j = 0;j < 3;j++) | |
x [i] [j] = Math.random (); | |
double sum = 0; | |
for (int i = 0;i < 3;i++) | |
for (int j = 0;j < 2;j++) { | |
for (int k = 0;k < 3;k++) { | |
e [k] = x [pairs [i] [j] [0]] [k] - x [pairs [i] [j] [1]] [k]; | |
for (int l = 0;l < 2;l++) | |
t [l] [k] = x [pairs [i] [j] [0]] [k] - x [pairs [i] [1 - j] [l]] [k]; | |
} | |
double dot = 0; | |
s [0] = s [1] = 0; | |
for (int k = 0;k < 3;k++) { | |
for (int l = 0;l < 2;l++) { | |
n [l] = e [(k + 1) % 3] * t [l] [(k + 2) % 3] - e [(k + 2) % 3] * t [l] [(k + 1) % 3]; | |
s [l] += n [l] * n [l]; | |
} | |
dot += n [0] * n [1]; | |
} | |
sum += Math.acos (dot / Math.sqrt (s [0] * s [1])); | |
} | |
max = Math.max (max,sum); | |
min = Math.min (min,sum); | |
} | |
System.out.println ("minimum : " + min / Math.PI); | |
System.out.println ("maximum : " + max / Math.PI); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment