如何放大我的代码(mandelbrot) [英] how to do zoom in my code (mandelbrot)
本文介绍了如何放大我的代码(mandelbrot)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码,我想知道如何将zoom插入我的代码中.(我读过一些类似的主题,但我不知道).
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;
}
推荐答案
以这种方式缩放还不够;您必须将所选区域的角映射到复杂平面中的点,然后重新生成Mandelbrot映射以获取新坐标.
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.
这篇关于如何放大我的代码(mandelbrot)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文