import ORG.netlib.math.complex.Complex; import processing.core.*; public class mobiusFixedPoints extends PApplet{ private static final long serialVersionUID = 1L; int windowsize=300; float dt=0.01f; float unitLength = windowsize/4; Complex a= new Complex(1,0); Complex b= new Complex(1,0f); Complex c= new Complex(0,.8); Complex d= new Complex(0.8f,0.8f); Complex grid[] = new Complex[1600]; Complex fixedPoint1; Complex fixedPoint2; public void setup() { size(windowsize, windowsize); background(255); loop(); smooth(); frameRate(120); c=(a.mul(d)).sub(new Complex(1,0)).div(b); initializeGrid(); fixedPoints(a,b,c,d); } public void draw() { Complex zImage; pushMatrix(); translate(windowsize/2+5,windowsize/2-5); scale(0.95f,-0.95f); stroke(80,50,50); strokeWeight(0.1f); // apply, iteratively, the Mobius transformation to the grid of points and move a bit in that direction for(int counter=0; counter<1600; counter++) { zImage = grid[counter].add(new Complex(dt,0).mul(Mobius(grid[counter],a,b,c,d).sub(grid[counter]))); line(unitLength*(float)grid[counter].re(), unitLength*(float)grid[counter].im(), unitLength*(float)zImage.re(), unitLength*(float)zImage.im()); grid[counter]=zImage; } // now draw the fixed points fill(255,0,0); noStroke(); rect(unitLength*(float) fixedPoint1.re()-3, unitLength*(float) fixedPoint1.im()-3, 6,6); rect(unitLength*(float) fixedPoint2.re()-3, unitLength*(float) fixedPoint2.im()-3, 6,6); popMatrix(); } public void mouseReleased() { //saveFrame("Mobius-##.tif"); b=new Complex(-2+((float) mouseX)/unitLength,-2+((float) mouseY)/unitLength); c=(a.mul(d)).sub(new Complex(1,0)).div(b); b=new Complex(-2+((float) mouseY)/unitLength,0); initializeGrid(); noStroke(); fill(255,255,255); rect(0,0,windowsize,windowsize); stroke(255,0,0); fill(255,0,0); //text("A: "+ a+", B: "+ b,10,10); fixedPoints(a,b,c,d); } void initializeGrid() { for(int counter=0; counter<1600; counter++) { grid[counter] = new Complex(-2+0.1*(counter%40), -2+0.1*(counter/40)); } } Complex Mobius(Complex z, Complex a, Complex b, Complex c, Complex d) { Complex num = (a.mul(z)).add(b); Complex den = (c.mul(z)).add(d); //Complex num = (z.sub(a)).mul(z.sub(b)); //Complex den = (z.sub(c)).mul(z.sub(d)); return (num.div(den)); } void fixedPoints(Complex a, Complex b, Complex c, Complex d) { Complex disc = (a.sub(d)).mul((a.sub(d))).add(new Complex(4,0).mul(b).mul(c)); fixedPoint1 = (a.sub(d).add(disc.sqrt())).div(new Complex(2,0).mul(c)); fixedPoint2 = (a.sub(d).sub(disc.sqrt())).div(new Complex(2,0).mul(c)); } static public void main(String args[]){ PApplet.main(new String[]{"MobiusCirclesDifferentialModel2"}); } }