запуск private void button3_Click object sender EventArgs if tochki Co

 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
43
44
45
// запуск
private void button3_Click(object sender, EventArgs e)
{
if (tochki.Count <= 1)
{
MessageBox.Show("Мало точек!", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
tochki.Insert(0, tochki[0]);
tochki.Add(tochki[tochki.Count - 1]);
tochki.Insert(0, tochki[0]);
tochki.Add(tochki[tochki.Count - 1]);
bspl_3(tochki);
}
}
//.......
private void bspl_3(List<Point>tochki)
{
int oldX , oldY , newX, newY;
int counter = tochki.Count;
int i = 0;
oldX = (tochki[i].X + tochki[i + 1].X) /2;
oldY = (tochki[i].Y + tochki[i + 1].Y )/2;
for( i = 0; i < counter - 3; i++)
{
for(float u = 0.0f; u < 1.0f; u+= 0.1f)
{
newX = (int)(tochki[i].X * (((1 - u) * (1 - u) * (1 - u)) / 6)
+ tochki[i + 1].X * ((3 * u * u * u - 6 * u * u + 4) / 6)
+ tochki[i + 2].X * ((-3 * u * u * u + 3 * u * u + 3 * u + 1) / 6)
+ tochki[i + 3].X * ((u * u * u) / 6));
newY = (int)(tochki[i].Y * (((1 - u) * (1 - u) * (1 - u)) / 6)
+ tochki[i + 1].Y * ((3 * u * u * u - 6 * u * u + 4) / 6)
+ tochki[i + 2].Y * ((-3 * u * u * u + 3 * u * u + 3 * u + 1) / 6)
+ tochki[i + 3].Y * ((u * u * u) / 6));
g.DrawLine(Kist_3, oldX, oldY, newX, newY);
oldX = newX;
oldY = newY;
}
}
}