how to do zoom in my code (mandelbrot)

匆匆过客 提交于 2020-01-17 01:19:30

问题


i have the following code and i wanted to know how may i insert zoom into my code.(i read some similar subjects but i can't figure).

GLsizei width = 600;
GLsizei height = 600;
int max = 500;
double xpos=0,ypos=0;

double xmax = 2.0;
double xmin = -2.0;
double ymax = 2.0;
double ymin = -2.0;

using namespace std;

void display()
{
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluOrtho2D(-2, width, -2, height);
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT );
  mandelbrot();
  glutSwapBuffers();
}


void reshape(GLsizei w, GLsizei h) {

width=w; height=h;
glViewport(0,0,width,height);
glutPostRedisplay();
 }



 void setXYpos(int px, int py)
{  
xpos=xmin+(xmax-xmin)*px/width;
ypos=ymax-(ymax-ymin)*py/height;

 }



    void mandelbrot()
     {
     ...}

   int main(int argc, char *argv[])
 {

glutInit(&argc, argv);
glutInitWindowSize(600, 600);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutCreateWindow("Mandelbrot");
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();

return 0;
}

回答1:


It's not enough to zoom in this way; you have to map the corners of the selected region to points in the complex plane and re-generate the Mandelbrot mapping for the new coordinates.



来源:https://stackoverflow.com/questions/5705554/how-to-do-zoom-in-my-code-mandelbrot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!