Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void magnify(int newCenterRow, int newCenterCol, int magnificationFactor){
- int centerRow = this.rows/2;
- int centerCol = this.cols/2;
- double realTop, imgTop;
- //calculate the new value of the top left corner.
- realTop = this.topLeftCorner.getReal() + this.xStepSize * newCenterCol;
- imgTop =this.topLeftCorner.getImg() - this.yStepSize * newCenterRow;
- this.topLeftCorner = new Complex(realTop, imgTop);
- this.xStepSize =(double)(this.xStepSize/magnificationFactor);
- this.yStepSize =(double)(this.yStepSize/magnificationFactor);
- //change the image
- this.shift(0,0, centerRow, centerCol);
- }
- /**
- * Shift this Mandelbrot plane such the source point (srcRow,srcCol) will move to (destRow,destCol).
- * @param srcRow - Row of the origin point.
- * @param srcCol - Column of the origin point.
- * @param destRow - Row of the destination point.
- * @param destCol - Column of the destination point.
- */
- public void shift(int srcRow, int srcCol, int destRow, int destCol){
- int newRow = destRow-srcRow;
- int newCol = destCol-srcCol;
- //calculate the new top left corner.
- double newReal = this.topLeftCorner.getReal() - newCol* this.xStepSize;
- double newImg = this.topLeftCorner.getImg() + newRow*this.yStepSize;
- this.topLeftCorner = new Complex(newReal, newImg);
- }
Add Comment
Please, Sign In to add comment