废话不多,需要安装python,和matplotlib、numpy等库,安装不全的,自行安装一下
在windows下测试通过
# -*- coding: utf-8 -*-
#需要安装matplotlib、numpy等库才能运行
import numpy as np
import pylab as pl
import time
from matplotlib import cm
def iter_point2(x,y):
#初始化公式的参数,需要改的话,可以改参数
a = 1
b = 1.75
iter = 0 #初始化迭代次数
for i in xrange(1, 10):
iter = i
dist = (x*x + y*y) #计算摸长,看是否超过最大限度
dist *= dist
#print "dist:" + str(dist)
if dist > 200: #如果超出了最大长度,就跳出循环,返回这个迭代次数
break
#临时保存一下x和y
tempx = x
tempy = y
#这里是公式 X = a-b|x| + y ; Y = 0.3x;
x = a - b*abs(tempx) + tempy
y = 0.3*tempx
return iter
#绘制图形时,以cx,xy