概述

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. IMX6 PCA9698应用层读写库

    .c #include <stdio.h> #include <string.h> #include <linux/types.h> #include <st ...

  2. 关于oracle中to_char和to_date的用法

      一.24小时的形式显示出来要用HH24 select to_char(sysdate,'yyyy-MM-dd HH24:mi:ss') from dual; select to_date('200 ...

  3. JavaScript 基础(七) 箭头函数 generator Date JSON

    ES6 标准新增了一种新的函数: Arrow Function(箭头函数). x => x *x 上面的箭头相当于: function (x){ return x*x; } 箭头函数相当于匿名函 ...

  4. 8.4 H5知识点总结

    HTML简介 HyperText Markup Language 简称为HTML HyperText: 超文本 (文本 + 图片 + 视频 + 音频 + 链接) Markup Language: 标记 ...

  5. 在MS SQLSERVER中如何最快的速度清空所有用户表的数据

    有时候我们需要清空数据库中所有用户表的数据,如果一张表一张表的清空的话,遇到一个庞大的数据系统估计得崩溃了.  用游标加上用变量来引用表名就可以做到这一点. 用变量来引用表名对表操作可以用在存储过程中 ...

  6. Shape comparison language

      形状比较语言, 九交模型 In this topic About shape comparison language Dimensionality Extensions to the CBM SC ...

  7. jqeury 合并单元格

    function mergeCells() { var tbodyTlth = $("#datatable_ajax1 tbody").find("tr").l ...

  8. asp.net GridView控件中诗选全选和全不选功能

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...

  9. 安装和部署ZkeaCMS

    ZkeaCMS是基于EasyFrameWork,使用ASP.NET MVC4开发的开源CMS. ZkeaCMS一个内容管理软件(网站).ZkeaCMS不仅只是管理内容,更是重新定义了布局.页面和组件, ...

  10. python之优雅处理套接字错误

    #!/usr/local/bin/python3.5 #coding:utf-8 import sys import socket import argparse def main(): #setup ...