using System using System Collections Generic using System ComponentMo

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
//сегмент кубического сплайна
PointF x1 = new PointF(152, 140);
PointF x2 = new PointF(260, 60);
PointF p1 = new PointF(1, 1);
PointF p2 = new PointF(1, 1);
float t2 = (float)Math.Sqrt((x2.X - x1.X) * (x2.X - x1.X) + (x2.Y - x1.Y) * (x2.Y - x1.Y));
for (float t = 0; t <= t2; t+=0.01f)
{
float X = x1.X + t + (3 * (x2.X - x1.X) / (t2 * t2) - 2 / t2 - 1 / t2) * t * t + (2 * (x1.X - x2.X) / (t2 * t2 * t2) + 1 / (t2 * t2) + 1 / (t2 * t2)) * t * t * t;
float Y = x1.Y + t + (3 * (x2.Y - x1.Y) / (t2 * t2) - 2 / t2 - 1 / t2) * t * t + (2 * (x1.Y - x2.Y) / (t2 * t2 * t2) + 1 / (t2 * t2) + 1 / (t2 * t2)) * t * t * t;
Graphics test = e.Graphics;
test.DrawEllipse(new Pen(Color.Black), X, Y, 5, 5);
}
}
}