/* Java Applet "Thin" computes the solution to the thin obstacle problem for the Dirichlet integral, for variable obstacle height and boundary values. This program is released under the GNU GPL; copyright is retained by the author, Danny Calegari. See http://www.gnu.org For information about the thin obstacle problem, see the following paper: J. Nitsche, "Variational problems with inequalities as boundary conditions; or How to Fashion a Cheap Hat for Giacometti's Brother" Arch. Rational Mech. Anal. (35) pp. 83-112 For applications of the thin obstacle problem to shrinkwrapping and a proof of the tameness conjecture, see: D. Calegari and D. Gabai, "Shrinkwrapping and the taming of hyperbolic 3-manifolds", eprint math.GT/0407151 */ import java.applet.Applet; import java.awt.*; import java.awt.geom.*; import java.awt.event.*; import java.lang.Math; public class thin2 extends Applet implements MouseListener, MouseMotionListener, ActionListener { int i,j,k,l; int a,b,c,d,e; int x,y; int dragwhichx,dragwhichy; int dragwherex,dragwherey; int guessX,guessY; double r,s; double m,n; double height[][]; double hit[][]; int reflect; int polyx[],polyy[]; int besterror,errorterm; int currentX, currentY; Polygon poly; int maxheight; Scrollbar mh = new Scrollbar(Scrollbar.HORIZONTAL,20,10,120,260); boolean adjuststate; boolean dragging; boolean gridon; Button adjustbutton, solvebutton, raisebutton, lowerbutton, gridbutton; public void init() { setLayout( new FlowLayout(10)); addMouseListener(this); addMouseMotionListener(this); adjustbutton = new Button("Adjust boundary values"); add(adjustbutton); adjustbutton.addActionListener(this); solvebutton = new Button("Solve thin obstacle problem"); add(solvebutton); solvebutton.addActionListener(this); raisebutton = new Button("Raise obstacle"); add(raisebutton); raisebutton.addActionListener(this); lowerbutton = new Button("Lower obstacle"); add(lowerbutton); lowerbutton.addActionListener(this); gridbutton = new Button("Grid on/off"); add(gridbutton); gridbutton.addActionListener(this); height = new double[40][40]; hit = new double[40][40]; poly = new Polygon(); polyx = new int[4]; polyy = new int[4]; maxheight=170; m=0.0; for(i=0;i<40;i++){ n=0.0; for(j=0;j<40;j++){ height[i][j]=100+70*(Math.sin(m/5.0))+100*(Math.cos(n/6.0)); if(j==i){ if (height[i][j]