using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int N = 10;
double[] data = new double[5000];
double[,] data_small;
Color[] colors;
private void Form1_Resize(object sender, EventArgs e)
{
// Refresh();
}
private void Form1_Load(object sender, EventArgs e)
{
data_small = new double[N, 5000];
int i = 0;
colors = new Color[N];
Random rand = new Random();
for (int xx = 0; xx < N; xx++)
{
colors[xx] = Color.FromArgb(rand.Next(100), rand.Next(100), rand.Next(100));
}
for (double x = 0; i < data.Length; x += 0.1, i++)
{
for (int n = 1; n < N; n+=2)
{
data[i] += (8.0 / (Math.PI * Math.PI)) * Math.Pow(-1, (n - 1) / 2) / (n * n) * Math.Sin(n * Math.PI * x / 50);
data_small[n, i] += (8.0 / (Math.PI * Math.PI)) * Math.Pow(-1, (n - 1) / 2) / (n * n) * Math.Sin(n * Math.PI * x / 50);
//data[i] += 4.0 / Math.PI * 1.0 / n * Math.Sin(n * Math.PI * x / 50);
// data_small[n, i] += 8.0 / Math.PI * 1.0 / n * Math.Sin(n * Math.PI * x / 50);
//data[i] += (1/2)+(1.0 / Math.PI * 1.0 / n * Math.Sin(n * Math.PI * x / 50));
//data_small[n, i] += 8.0/(1.0 / Math.PI * 1.0 / n * Math.Sin(n * Math.PI * x / 50));
}
}
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Point now = new Point(0, 0);
Point last = new Point(0, 0);
double stepx = (double)this.Width / data.Length;
double x = 0;
for (int i = 0;i < data.Length; i++)
{
now = new Point((int)x, (int)(data[i] * 200) + this.Height/2);
e.Graphics.DrawLine(new Pen(Color.Red,3), now, last);
last = now;
x += stepx;
}
for (int n = 1; n < N; n += 2)
{
last = new Point(0, 0);
x = 0;
for (int i = 0; i < data.Length; i++)
{
now = new Point((int)x, (int)(data_small[n,i] * 200) + this.Height / 2);
e.Graphics.DrawLine(new Pen(colors[n],3), now, last);
last = now;
x += stepx;
}
}
}
private void Form1_SizeChanged(object sender, EventArgs e)
{
}
private void Form1_Move(object sender, EventArgs e)
{
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น