首页 > 应用开发 > IT综合 > 分形图形.美丽的复变函数(图,评,代码) (转)
程序实现的图形为:XML:namespace prefix = o ns = "urn:schemas-microsoft-com:Office:office" />
2003-7-222334290.gif" align=baseline border=0>
图形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
{
///
/// Form1 的摘要说明。
///
public class Form1 : System.Windows.Forms.Form
{
///
/// 必需的设计器变量。
///
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;
}
///
/// 清理所有正在使用的资源。
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows FoRM Designer generated code
///
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
///
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
///
/// 应用程序的主入口点。
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
///
/// 重载 OnPaint
///
///
protected override void OnPaint(PaintEventArgs e)
{
DrawPicture(e,0.2541);
base.OnPaint(e);
}
///
/// 绘制分形图形
///
///
///
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 { for(int j=0;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 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; } } } } } /// /// 迭代复变函数(部分) /// /// /// /// /// /// /// 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; } } }
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10748419/viewspace-960673/ ,如需转载,请注明出处,否则将追究法律责任。