private void thirdSpline List Point Double oldX oldY Double newX newY

 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
private void thirdSpline(List<Point> P)
{
Double oldX = 0.0, oldY = 0.0;
Double newX, newY;
for (int i = 0; i < P.Count - 3; i++)
{
for (Double t = 0; t < 1; t += 0.1)
{
newX = P[i].X * (((1 - t) * (1 - t) * (1 - t)) / 6)
+ P[i + 1].X * ((3 * t * t * t - 6 * t * t + 4) / 6)
+ P[i + 2].X * ((-3 * t * t * t + 3 * t * t + 3 * t + 1) / 6)
+ P[i + 3].X * ((t * t * t) / 6);
newY = P[i].Y * (((1 - t) * (1 - t) * (1 - t)) / 6)
+ P[i + 1].Y * ((3 * t * t * t - 6 * t * t + 4) / 6)
+ P[i + 2].Y * ((-3 * t * t * t + 3 * t * t + 3 * t + 1) / 6)
+ P[i + 3].Y * ((t * t * t) / 6);
if (t == 0)
{
g.DrawLine(redBrush, (float)newX, (float)newY, (float)newX, (float)newY);
oldX = newX;
oldY = newY;
}
g.DrawLine(redBrush, (float)oldX, (float)oldY, (float)newX, (float)newY);
oldX = newX;
oldY = newY;
}
}
}