Guest User

Untitled

a guest
Apr 22nd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.32 KB | None | 0 0
  1.     public void magnify(int newCenterRow, int newCenterCol, int magnificationFactor){
  2.  
  3.         int centerRow = this.rows/2;
  4.         int centerCol = this.cols/2;
  5.  
  6.         double realTop, imgTop;
  7.         //calculate the new value of the top left corner.
  8.         realTop = this.topLeftCorner.getReal() + this.xStepSize * newCenterCol;
  9.         imgTop =this.topLeftCorner.getImg() - this.yStepSize * newCenterRow;
  10.        
  11.         this.topLeftCorner = new Complex(realTop, imgTop);
  12.        
  13.         this.xStepSize =(double)(this.xStepSize/magnificationFactor);
  14.         this.yStepSize =(double)(this.yStepSize/magnificationFactor);
  15.        
  16.         //change the image
  17.         this.shift(0,0, centerRow, centerCol);
  18.     }
  19.  
  20.     /**
  21.      * Shift this Mandelbrot plane such the source point (srcRow,srcCol) will move to (destRow,destCol).
  22.      * @param srcRow - Row of the origin point.
  23.      * @param srcCol - Column of the origin point.
  24.      * @param destRow - Row of the destination point.
  25.      * @param destCol - Column of the destination point.
  26.      */
  27.     public void shift(int srcRow, int srcCol, int destRow, int destCol){
  28.  
  29.         int newRow = destRow-srcRow;
  30.         int newCol = destCol-srcCol;
  31.         //calculate the new top left corner.
  32.         double newReal = this.topLeftCorner.getReal() - newCol* this.xStepSize;
  33.         double newImg = this.topLeftCorner.getImg() + newRow*this.yStepSize;
  34.        
  35.         this.topLeftCorner = new Complex(newReal, newImg);
  36.     }
Add Comment
Please, Sign In to add comment