//■グモースキーとミラの写像 // label1(Text="a"),label2(Text="b"),label3(Text="Δμ"),label4(Text="μ="), // textBox1(Text="0.008", aの値), textBox2(Text="0.05", bの値), // textBox3(Text="0.0005", Δμの値), button1(Text="実行8"),timer1を貼り付けます。 // テキストボックスのTextAlignはRightにしておくほうがよいでしょう。 // フォームのサイズは大きめにとっておくほうがよいでしょう。 // button1のClickイベントハンドラをbutton1_Clickとして設定します。 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Image image; public Boolean drawFlag = false; float mu, a, b, dm; public Form1() { InitializeComponent(); drawFlag = false; } public void draw(float mu, float a, float b) { Brush brush = new SolidBrush(Color.DarkGreen); image = new Bitmap(1000, 1000); Graphics g = Graphics.FromImage(image); g.Clear(this.BackColor); float X, Y, G;//以下グモウスキーとミラの写像の計算と描画 X = 0.1F; Y = 0; G = mu * X + 2 * (1 - mu) * X * X / (1 + X * X); for (int i = 0; i < 10000; i++) { float XP = 300 - X * 5; float YP = 200 - Y * 5; g.FillRectangle(brush, XP, YP, 1F, 1F); float XN = X; X = Y + a * (1 - b * Y * Y) * Y + G; G = mu * X + 2 * (1 - mu) * X * X / (1 + X * X); Y = -XN + G; } drawFlag = true; this.Invalidate(); } protected override void OnPaint(PaintEventArgs e) { if (drawFlag) { base.OnPaint(e); e.Graphics.DrawImage(image, 10, 10); } } private void button1_Click(object sender, EventArgs e) { a = float.Parse(textBox1.Text); b = float.Parse(textBox2.Text); dm = float.Parse(textBox3.Text); mu = -1 + dm; draw(mu, a, b); timer1.Enabled = true; } private void timer1_Tick(object sender, EventArgs e) { mu = mu + dm; label5.Text = "μ : " + mu.ToString("0.00000"); draw(mu, a, b); if (Math.Abs(1 - mu-dm) < dm) timer1.Enabled = false; } } }