Mandelbrot和Julia
概述
mandelbrot
julia
Mandelbrot
对全体复数z,满足xn+1 = xn2 + z从x0 = 0起,|x|随n值增加不趋于无穷大,则z属于Mandelbrot集
代码
#include <glut.h> int g_width, g_height; /*********************************
input: z = a + bi
MaxIteration,迭代次数上限
output: 灰度级n
*********************************/
int GrayLevel(double a, double b, int MaxIteration)
{
double x = , y = , xx = , yy = ;
int n = ;
while(n++ < MaxIteration)
{
y = * x * y + b;
x = xx - yy + a;
xx = x * x;
yy = y * y;
if ((xx + yy) > )
{
return n;
}
}
return ;
} void myDisplay()
{
double min_a, max_a, min_b, max_b, step_a, step_b, a, b;
int MaxIteration = ;
int Iteration;
float scale = 255.0 / MaxIteration;
int x,y;
min_a = -2.0;
max_a = 0.5;
min_b = -1.25;
max_b = 1.25;
step_a = (max_a - min_a) / g_width;
step_b = (max_b - min_b) / g_height; glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POINTS);
a = min_a;
for (x = ; x < g_width; x++)
{
b = min_b;
for (y = ; y < g_height; y++)
{
Iteration = - scale * GrayLevel(a, b, MaxIteration);
glColor3ub(Iteration, Iteration, Iteration);
glVertex2i(x, y);
b += step_b;
}
a += step_a;
}
glEnd();
glFlush();
} void reshape(GLsizei width, GLsizei height)
{
float w_aspect = 4.0 / 3.0;
float aspect = ((float)width) / height; g_width = width;
g_height = height; if (aspect <= w_aspect)
{
glViewport(, (height - width / w_aspect) / ,
width, width / w_aspect);
} else
glViewport((width - height * w_aspect) / , ,
height * w_aspect, height); glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-0.0, 400.0, -0.0, 300.0);
} void main(int argc, char* *argv)
{
glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE); glutInitWindowSize(, ); glutInitWindowPosition(, ); glutCreateWindow("Mandelbort"); glClearColor(0.0, 0.0, 0.0, 0.0); glutDisplayFunc(&myDisplay); glutReshapeFunc(reshape); glutMainLoop();
}
结果如下

Julia集
在xn+1 = xn2 + z,对给定的复数z,所有使|x|不发散的x0属于Julia集
给定的z = -0.7454 + 0.1131i;x0的实部为[-1.6,1.6],虚部为[-1.2,1.2]
代码
#include <glut.h> int g_width, g_height; /*********************************
输入: z = a + bi
MaxIteration,迭代次数上限
输出: 灰度级n, 0表示白色
思路:
*********************************/
int GrayLevel(double x, double y, int MaxIteration)
{
double xx, yy, zx = -0.7454, zy = 0.1131;
int n = ;
xx = x * x;
yy = y * y;
while(n++ < MaxIteration)
{
y = * x * y + zy;
x = xx - yy + zx;
xx = x * x;
yy = y * y;
if ((xx + yy) > )
{
return n;
}
}
return ;
}
结果如下:

Mandelbrot和Julia的更多相关文章
- leaflet地图库
an open-source JavaScript libraryfor mobile-friendly interactive maps Overview Tutorials Docs Downlo ...
- 混沌分形之朱利亚集(JuliaSet)
朱利亚集合是一个在复平面上形成分形的点的集合.以法国数学家加斯顿·朱利亚(Gaston Julia)的名字命名.我想任何一个有关分形的资料都不会放过曼德勃罗集和朱利亚集.这里将以点集的方式生成出朱利亚 ...
- Julia is a high-level, high-performance dynamic programming language for technical computing, with syntax that is familiar to users of other technical
http://julialang.org/ julia | source | downloads | docs | blog | community | teaching | publications ...
- 在天河二号上对比Julia,Python和R语言
Julia是一款高级高效为技术计算(technical computing)而设计的编程语言,其语法与其他计算环境类似.其为分布式计算和并行所设计,最知名的地方在于其接近C语言的高效率. 按开发者的话 ...
- 使用OpenGL进行Mandelbrot集的可视化
Mandelbrot集是哪一集?? Mandelbrot集不是哪一集!! 啊不对-- Mandelbrot集是哪一集!! 好像也不对-- Mandelbrot集是数集!! 所以--他不是一集而是数集? ...
- [原创+分享]Mandelbrot Explorer
Mandelbrot Explorer 是一款用于在MandelBort集/Julia集上进行无限漫游的软件,使用VS2013+CUDA6.5开发而成.它也是我学习CUDA开发的一个小小的成果,欢迎大 ...
- OpenCV绘制朱利亚(Julia)集合图形
朱利亚集合是一个在复平面上形成分形的点的集合.以法国数学家加斯顿·朱利亚(Gaston Julia)的名字命名. 朱利亚集合可以由下式进行反复迭代得到: 对于固定的复数c,取某一z值(如z = z0) ...
- 数量经济学推荐的Julia教程
http://quant-econ.net/jl/learning_julia.html Julia最为号称和c媲美的运行速度,想python一下简单的语法,虽然发展还不完善,但任然值得去关注. Ju ...
- julia的优化?
julia> function fib1(n) if n==1 return n else return n+fib1(n-1) end end fib1 (generic function w ...
随机推荐
- mongodb根据字符长度作为条件查询
{ $where:"this.XXX.length==2" } 用$where条件查询,等号要用==.虽说$where查询可能效率不是很好,这只是我能想到的,有更好的方法欢迎指教
- SQLite 命令
在shell下直接敲 sqlite3 进入sqlite命令行模式下(CLP的shell模式,CLP是sqlite3的命令行程序) sqlite3 -help (注意有空格)显示命令行模式下,sqli ...
- 7.arm汇编 bic和orr指令
1. bic BIC指令的格式为: BIC{条件}{S} 目的寄存器,操作数1,操作数2 BIC指令用于清除操作数1的某些位,并把结果放置到目的寄存器中. 操作数1应是一个寄存器, 操作数2可以是一 ...
- 【EF学习笔记12】----------解释查询和本地查询 区分 Enumerable 和 Queryable
简单介绍:Enumerable 和 Queryable 他们都是静态类,位于命名控件 System.Linq下,分别为IEnumerable<T>和IQueryable<T>提 ...
- 【转载】OpenGL ES 三种类型修饰 uniform attribute varying
其实attribute varying已经被in和out代替了,但是有些工程代码里面仍然还在,所以权当笔记好了. 1.uniform变量uniform变量是外部application程序传递给(ver ...
- 移动端WEB开发,click,touch,tap事件浅析
一.click 和 tap 比较 两者都会在点击时触发,但是在手机WEB端,click会有 200~300 ms,所以请用tap代替click作为点击事件. singleTap和doubleTap 分 ...
- c 数据拼接
char buf1[] = {0x31,0x32,0x33,0x00,0x51,0x52,0x53,0xaa,0xbb,0xcc,0x00}; int a=0xabcd6799; int b=0x88 ...
- python模块使用案例
python模块使用案例 一.使用MySQLdb模块代码示例: # 导入 MySQLdb模块 import MySQLdb # 和服务器建立链接,host是服务器ip,我的MySQL数据库搭建在本机, ...
- win7 64位 mongodb2.6.0 安装服务启动
Workaround to install as a service You can manually install 2.6.0 as a service on Windows from an Ad ...
- Android测试——adb命令
Adb (Android Debug Bridge)起到调试桥的作用. 通过adb我们可以在Eclipse中方便通过DDMS来调试Android程序.adb采用监听Socket TCP 5554等端口 ...