分形图形.美丽的复变函数(图,评,代码)

王朝other·作者佚名  2006-01-08
窄屏简体版  字體: |||超大  

程序实现的图形为:

图形1:复变函数 f(z)=z1*z2+0.2541;

其中 z1=3*x+(3/11)*y*i;

z2=(3*7)*x+3*y*i;

///DrawPicture(e,0.2541);

///mult(x*3,y*3/11,x*3/7,y*3,ref x,ref y);

数学的美丽,是一种抽象的美。

可是,如果您是有心人,如果您发自内心的喜爱那音律般的美丽,那“计算”的节奏,或紧迫,或舒缓,有如天籁般的声音,您就会不由自主的去捕捉……

记得有一次去武汉音乐学院的主页去,看到一篇论文,讲的是演化计算来“谱写”音乐。原来音乐家早已心有戚戚焉……

捕捉“音律”,或需要些专业知识。可是,把那节奏,那韵律,转化为像素,却是你我都能做到的----哦,分形,这里又是你的灵魂的舞台,像素点就是你轻快的舞步落处,你是否愿意与我共舞一曲?

来吧,让我牵起你的手……

来吧,您也加入吧……

图形1是我最喜欢的一幅,看中间浮雕般的效果,我心里渐渐的涌起一股感动:多么具有古典气质的图案呵,千百年来,她竟然隐身于这幅分形图形当中。

代码如下(c#):

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;

namespace picture

{

/// <summary>

/// Form1 的摘要说明。

/// </summary>

public class Form1 : System.Windows.Forms.Form

{

/// <summary>

/// 必需的设计器变量。

/// </summary>

private System.ComponentModel.Container components = null;

private Pen redPen=new Pen(Color.Red,0);

private Pen greenPen=new Pen(Color.Green,0);

private Random randNum=new

Random(unchecked((int)DateTime.Now.Ticks));

private double zoom=2.0;

private double attract=0.0001;

public Form1()

{

//

// Windows 窗体设计器支持所必需的

//

InitializeComponent();

//

// TODO: 在 InitializeComponent 调用后添加任何构造函数代码

//

this.BackColor=Color.Green;

}

/// <summary>

/// 清理所有正在使用的资源。

/// </summary>

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

#region Windows Form Designer generated code

/// <summary>

/// 设计器支持所需的方法 - 不要使用代码编辑器修改

/// 此方法的内容。

/// </summary>

private void InitializeComponent()

{

//

// Form1

//

this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);

this.BackColor = System.Drawing.Color.LightGreen;

this.ClientSize = new System.Drawing.Size(488, 333);

this.Name = "Form1";

this.Text = "美丽的分形(复变函数)";

this.WindowState=System.Windows.Forms.FormWindowState.Maximized;

}

#endregion

/// <summary>

/// 应用程序的主入口点。

/// </summary>

[STAThread]

static void Main()

{

Application.Run(new Form1());

}

/// <summary>

/// 重载 OnPaint

/// </summary>

/// <param name="e"></param>

protected override void OnPaint(PaintEventArgs e)

{

DrawPicture(e,0.2541);

base.OnPaint(e);

}

/// <summary>

/// 绘制分形图形

/// </summary>

/// <param name="e"></param>

/// <param name="number"></param>

private void DrawPicture(PaintEventArgs e,double number)

{

Graphics dc= e.Graphics;

double scale,mag,x,y;

double maxX=this.Width,maxY=this.Height;

scale=2.0*zoom/maxY;

bool bContinue;

int iter;

for(int i=0;i<Math.Min(maxX,maxY);i++)

{

for(int j=0;j<Math.Min(maxX,maxY);j++)

{

x=scale*i-zoom;

y=zoom-scale*j;

bContinue=true;

iter=0;

while(bContinue)

{

mult(x*3,y*3/11,x*3/7,y*3,ref x,ref y);

x=x+number;

mag=x*x+y*y;

if(mag<attract)

bContinue=false;

else

if((mag<100)&&(iter<10000000)) iter+=1;

else

{

if(iter%2 ==1)//

dc.DrawEllipse(redPen,i+100,j,1,1);

else

dc.DrawEllipse(greenPen,i+100,j,1,1);

bContinue=false;

}

}

}

}

}

/// <summary>

/// 迭代复变函数(部分)

/// </summary>

/// <param name="x1"></param>

/// <param name="y1"></param>

/// <param name="x2"></param>

/// <param name="y2"></param>

/// <param name="x"></param>

/// <param name="y"></param>

private void mult(double x1,double y1,double x2,

double y2, ref double x, ref double y)

{

x=x1*x2-y1*y2;

y=x1*y2+x2*y1;

}

}

}

图形2:复变函数 f(z)=z1*z2+0.384;

其中 z1=3*x+(3/11)*y*i;

z2=(3*7)*x+3*y*i;

///DrawPicture(e,0.384);

///mult(x*3,y*3/11,x*3/7,y*3,ref x,ref y);

图形3:复变函数 f(z)=z1*z2+0.654;

其中 z1=x+y*i;

z2=(2*5)*x+(2/9)*y*i;

///DrawPicture(e,0.654);

///mult(x,y,x*2/5,y*2/9,ref x,ref y);

图形4:复变函数 f(z)=z1*z1+0.384;

其中 z1=x+y*i;

///DrawPicture(e,0.384);

///mult(x,y,x,y,ref x,ref y);

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航