扩大曼德布罗产生朱莉娅 [英] extending mandelbrot to generate julia

查看:221
本文介绍了扩大曼德布罗产生朱莉娅的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正在一个需要我使用相同代码的项目上工作,请注意在同一文件中生成mandelbrot集和julia集,我有一个有效的mandelbrot集,但可以看到如何使用相同代码扩展到julia set. 也许没有得到之间的区别?谁能详细说明

working on a project requiring me to use same code ,note in the same file to generate mandelbrot set and julia sets ,i hav a working mandelbrot set but can see how to extend to julia set using same code. maybe am not getting the differences between ? can anyone elaborate

import numpy as np
import matplotlib.pyplot as plt
import math



def Mandelbrot(zmin, zmax, m, n, tmax=256):

    xs = np.linspace(zmin, zmax, n)
    ys = np.linspace(zmin, zmax, m)
    X, Y = np.meshgrid(xs, ys)


    Z = X + 1j * Y
    C = np.copy(Z)
    M = np.ones(Z.shape) * tmax

    for t in xrange(tmax):
        mask = np.abs(Z) <= 2.
        Z[ mask] = Z[mask]**2 + C[mask]
        M[-mask] -= 1.
    return M

list=Mandelbrot(-2,2,500,500)
plt.imshow(list.T, extent=[-2, 1, -1.5, 1.5])
plt.gray()
plt.savefig('mandelbrot.png')

推荐答案

Mandelbrot 集是针对Julia集的特殊集,一些文档写道Mandelbrot集是ALL的索引集.茱莉亚集(只有一个索引集-Mandelbrot-并且有无限数量的茱莉亚集.)

The Mandelbrot set is a special set in terms of Julia sets, some documentation writes that the Mandelbrot set is the index set of ALL Julia sets (there is one and only one index set - the Mandelbrot - and there are infinite number of Julia sets.)

当您在Mandelbrot集合上计算一个点并遍历z^2 + c时,该c的值与您尝试确定该点是否为地图一部分的点相同.如果您转到下一个点(这就是您在计算中所做的那样),此c将会更改.

When you calculate a point on the Mandelbrot set and iterate over z^2 + c, this c takes the same value as the point you try to decide if it is part of the map or not. This c will change if you go to the next point (that is how you did in your calculation).

换句话说,您在进行迭代时的值为恒定,但对于每个不同的点都会变化.

In other words you have a value that is constant while you go through the iteration but will change for every different point.

当您计算Julia集时,计算结果是99.9%相同,除了在 entire 计算期间必须使用恒定的c值,而不仅仅是单个点.这就是为什么为了避免混淆而不将其命名为c的原因,而通常将其命名为k.

When you calculate Julia sets, the calculation is 99.9% the same except you have to use a c value that is constant during the entire calculation not just for a single point. And that is why it is not named as c to avoid confusion, but usually k.

现在,如果我对您感到困惑,解决方案将变得非常简单.您必须更改此设置:

Now if I confused you enough, the solution is dead simple. You have to change this:

Z[ mask] = Z[mask]**2 + C[mask]

对此:

Z[ mask] = Z[mask]**2 + (-0.8+0.156j)

在此处检查相同的设置: http://en.wikipedia.org/wiki/文件:Julia_set_camp4_hi_rez.png

Check the same set here: http://en.wikipedia.org/wiki/File:Julia_set_camp4_hi_rez.png

这篇关于扩大曼德布罗产生朱莉娅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆