如何对 Mandelbrot 集进行简单缩放

发布于 2024-12-19 07:47:04 字数 1100 浏览 1 评论 0原文

我对 Mandelbrot 设置“缩放”视图以及与之相关的数学有一个一般性问题。我已经实现了 256 X 256 窗口大小的 mandelbrot 集,其值

  // ImageWidth = ImageHeight = 256;

  double MinRe = -2.0;
  double MaxRe = 1.0;
  double MinIm = -1.2;
  double MaxIm = 1.8;

  ComputeMandelbrot();

接下来,我选择一个正方形区域,这些是左上角尖端 (76,55) 和最右下尖端 (116, 99) < 的坐标strong>(选择边长为 44 的正方形)

所以,我选择 x2 = x1 + 44 ; y2 = y1 + 44;

如何将这些新坐标转换到复平面?新的实部和虚部值将如何变化才能计算新的值集?

这是我到目前为止所尝试过的。

double Re_factor = (MaxRe-MinRe)/(ImageWidth-1);
double Im_factor = (MaxIm-MinIm)/(ImageHeight-1);

double newMinRe = MinRe + (Re_factor* x1);
double newMaxRe = MaxRe + (Re_factor* x2);
double newMinIm = MinIm + (Im_factor* y1);
double newMaxIm = MaxIm + (Im_factor* y2);

// and then I compute c - real and c- imag values

  for(unsigned y=0; y<ImageHeight; ++y) 
{ 
  double c_im = newMaxIm - y*Im_factor;
  for(unsigned x=0; x<ImageWidth; ++x)
    {
      double c_re = newMinRe + x*Re_factor;

      // ComputeMandelbrot();

     }

 }

我很难弄清楚数学,也很难生成“缩放”视图,并且感谢任何帮助!

I have a general question with the Mandelbrot set "zoom" view and the math pertaining to it. I have implemented the mandelbrot set for the 256 X 256 window size with values

  // ImageWidth = ImageHeight = 256;

  double MinRe = -2.0;
  double MaxRe = 1.0;
  double MinIm = -1.2;
  double MaxIm = 1.8;

  ComputeMandelbrot();

Next, I select a region of square and these are the coordinates for the upper left most tip (76,55), and rightmost bottom tip (116, 99) (square of side 44 is chosen)

so , I choose x2 = x1 + 44 ; y2 = y1 + 44;

How do I translate these new coordinates to the complex plane ? and how would the new real and imaginary values change in order to compute it for the new set of values ?

This is what I have tried so far..

double Re_factor = (MaxRe-MinRe)/(ImageWidth-1);
double Im_factor = (MaxIm-MinIm)/(ImageHeight-1);

double newMinRe = MinRe + (Re_factor* x1);
double newMaxRe = MaxRe + (Re_factor* x2);
double newMinIm = MinIm + (Im_factor* y1);
double newMaxIm = MaxIm + (Im_factor* y2);

// and then I compute c - real and c- imag values

  for(unsigned y=0; y<ImageHeight; ++y) 
{ 
  double c_im = newMaxIm - y*Im_factor;
  for(unsigned x=0; x<ImageWidth; ++x)
    {
      double c_re = newMinRe + x*Re_factor;

      // ComputeMandelbrot();

     }

 }

I am having a hard time figuring out the math, and also with regards to generating a 'zoom' view and any help is appreciated !!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

り繁华旳梦境 2024-12-26 07:47:04

这是一个线性缩放。让我们在一维中进行。您有屏幕空间(屏幕坐标)和图像空间(在您的情况下为复平面)

  • 屏幕空间 => [0, 255]
  • 图像空间 => [-2, 1]

因此,将坐标 X 从屏幕空间转换为图像空间 X'

X' = (X / 255) * (1 - (-2)) + (-2)

使其更通用的

  • 屏幕空间 = > [SMin,SMax]
  • 图像空间=> [IMin, IMax]

X' = ((X - SMin) / (SMax - SMin)) * (IMax - IMin) + IMin


在您的代码中,您所做的

double newMinRe = MinRe + (Re_factor* x1);

与我所展示的相同。但是你这样做

double newMaxRe = MaxRe + (Re_factor* x2);

是不正确的,并且应该是

double newMaxRe = MinRe + (Re_factor* x2);

循环中的相同问题,应该是

for(unsigned y=0; y<ImageHeight; ++y)  { 
  double c_im = MinIm + y*Im_factor;
  for(unsigned x=0; x<ImageWidth; ++x) {
    double c_re = MinRe + x*Re_factor;
    // ComputeMandelbrot();
  }
}

额外的额外细节:为了正确地对图像空间进行采样,我建议这个

for(unsigned SX = SMin; x < SMax; ++x) {
  double k = (double(SX + 0.5) - SMin) / (SMax - SMin);
  double IX = (k * (IMax - IMin)) + IMin;
}

+0.5项是在中间进行采样像素...

It's a linear scaling. Let's doing it in 1D. You have the screen space (screen coordinates), and the image space (the complex plane, in your case)

  • screen space => [0, 255]
  • image space => [-2, 1]

So to convert a coordinate X from screen space to image space X'

X' = (X / 255) * (1 - (-2)) + (-2)

To make it more generic

  • screen space => [SMin, SMax]
  • image space => [IMin, IMax]

X' = ((X - SMin) / (SMax - SMin)) * (IMax - IMin) + IMin


In your code, you do

double newMinRe = MinRe + (Re_factor* x1);

which is equivalent to what I show. But then you do

double newMaxRe = MaxRe + (Re_factor* x2);

which is not correct, and should be

double newMaxRe = MinRe + (Re_factor* x2);

Same problem in your loop, it should be

for(unsigned y=0; y<ImageHeight; ++y)  { 
  double c_im = MinIm + y*Im_factor;
  for(unsigned x=0; x<ImageWidth; ++x) {
    double c_re = MinRe + x*Re_factor;
    // ComputeMandelbrot();
  }
}

Additional detail for extra-goodness : to sample properly the image space , I suggest this

for(unsigned SX = SMin; x < SMax; ++x) {
  double k = (double(SX + 0.5) - SMin) / (SMax - SMin);
  double IX = (k * (IMax - IMin)) + IMin;
}

The +0.5 term is to sample right in the middle of the pixel...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文