概述

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的更多相关文章

  1. leaflet地图库

    an open-source JavaScript libraryfor mobile-friendly interactive maps Overview Tutorials Docs Downlo ...

  2. 混沌分形之朱利亚集(JuliaSet)

    朱利亚集合是一个在复平面上形成分形的点的集合.以法国数学家加斯顿·朱利亚(Gaston Julia)的名字命名.我想任何一个有关分形的资料都不会放过曼德勃罗集和朱利亚集.这里将以点集的方式生成出朱利亚 ...

  3. 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 ...

  4. 在天河二号上对比Julia,Python和R语言

    Julia是一款高级高效为技术计算(technical computing)而设计的编程语言,其语法与其他计算环境类似.其为分布式计算和并行所设计,最知名的地方在于其接近C语言的高效率. 按开发者的话 ...

  5. 使用OpenGL进行Mandelbrot集的可视化

    Mandelbrot集是哪一集?? Mandelbrot集不是哪一集!! 啊不对-- Mandelbrot集是哪一集!! 好像也不对-- Mandelbrot集是数集!! 所以--他不是一集而是数集? ...

  6. [原创+分享]Mandelbrot Explorer

    Mandelbrot Explorer 是一款用于在MandelBort集/Julia集上进行无限漫游的软件,使用VS2013+CUDA6.5开发而成.它也是我学习CUDA开发的一个小小的成果,欢迎大 ...

  7. OpenCV绘制朱利亚(Julia)集合图形

    朱利亚集合是一个在复平面上形成分形的点的集合.以法国数学家加斯顿·朱利亚(Gaston Julia)的名字命名. 朱利亚集合可以由下式进行反复迭代得到: 对于固定的复数c,取某一z值(如z = z0) ...

  8. 数量经济学推荐的Julia教程

    http://quant-econ.net/jl/learning_julia.html Julia最为号称和c媲美的运行速度,想python一下简单的语法,虽然发展还不完善,但任然值得去关注. Ju ...

  9. julia的优化?

    julia> function fib1(n) if n==1 return n else return n+fib1(n-1) end end fib1 (generic function w ...

随机推荐

  1. iOS 解析json串

    NSString *json = @"[{\"name\":\"a1\",\"items\":[{\"x1\" ...

  2. uniq,sort,

    语 法:uniq [-cdu][-f<栏位>][-s<字符位置>][-w<字符位置>][--help][--version][输入文件][输出文件]   补充说明: ...

  3. sqoop job 踩过的坑

    sqoop 执行可以以job形式 也可以执行用命令执行,再用sqoopjob时,踩了几个坑,分享一下 1.服务器重启 由于服务器增加硬盘,需要重启后,发现sqoop job 无法执行,报连接数据库IO ...

  4. Javascript调用ActiveX示例

      Javascript调用ActiveX示例   写一个ActiveX控件比如叫做MyNameSpace.SecreteInfo,安装在客户机器上,这样可以通过c++获取到机器的几乎任何信息. 在网 ...

  5. 关于Android开发手机连接不上电脑问题解决方案

    1.当然首先你得将手机里的usb debug选项选上,否则lsusb是不会有你的设备的2. lsusb 查看usb设备id3. sudo vim /etc/udev/rules.d/51-androi ...

  6. C#去掉list集合中的重复数据

    List<string> conList= new List<string>(); List<string> listII = new List<string ...

  7. 理解node模块的exports和module.exports

    exports是module.exports的引用,即var exports = module.exports.在一个模块的开头,这两个值都指向同一个空对象:exports = module.expo ...

  8. delphi项目中的modelsupport文件夹

    delphi项目中的modelsupport文件夹 今天写着写着突然发现多了一个这个文件夹..苦思不得其解  看着又难受  删了又重建 终于找到了  存此备查;Tools--option--toget ...

  9. machine learning----->什么是机器学习

    1.概述: 学习一门学问的第一步就是要了解这门学问到底是什么,它可以被用来干什么. 本文罗列了学习machine learning的过程中看到的一些写得比较好的文章以及读完这些文章之后对机器学习的初步 ...

  10. iOS9的新特性以及适配方案

    新的iOS 9系统比iOS8更稳定,功能更全面,而且还更加开放.iOS 9加入了更多的新功能,包括更加智能的Siri,新加入的省电模式.iOS 9为开发者提供5000个全新的API. 1. 限制HTT ...