запуск 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
46
47
/// запуск
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)
{
float oldX , oldY , newX, newY;
float counter = tochki.Count;
int i = 0;
oldX = (tochki[i].X + tochki[i + 1].X + tochki[i + 2].X) / 3;
oldY = (tochki[i].Y + tochki[i + 1].Y + tochki[i + 1].X) / 3;
for( i = 0; i < counter - 3; i++)
{
for(float t = 0.0f; t < 1.0f; t+= 0.1f)
{
newX = tochki[i].X * (((1 - t) * (1 - t) * (1 - t)) / 6)
+ tochki[i + 1].X * ((3 * t * t * t - 6 * t * t + 4) / 6)
+ tochki[i + 2].X * ((-3 * t * t * t + 3 * t * t + 3 * t + 1) / 6)
+ tochki[i + 3].X * ((t * t * t) / 6);
newY = tochki[i].Y * (((1 - t) * (1 - t) * (1 - t)) / 6)
+ tochki[i + 1].Y * ((3 * t * t * t - 6 * t * t + 4) / 6)
+ tochki[i + 2].Y * ((-3 * t * t * t + 3 * t * t + 3 * t + 1) / 6)
+ tochki[i + 3].Y * ((t * t * t) / 6);
g.DrawLine(Kist_1, (float)oldX, (float)oldY, (float)newX, (float)newY);
oldX = newX;
oldY = newY;
}
}
}