Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.94 KB | None | 0 0
  1. private void GetPointsForSpline(Dictionary<double, double> points)
  2.         {
  3.             Dictionary<double, double> newPoints = new Dictionary<double, double>();
  4.             for (int x = 3; x < 9; x++)
  5.             {
  6.                 for (double t = 0; t <= 1; t = t + 0.01)
  7.                 {
  8.                     Matrix<double> Tmatrix = DenseMatrix.OfArray(new double[,]
  9.                     {
  10.                         {Math.Pow(t, 3), Math.Pow(t, 2), t, 1}
  11.                     });
  12.                     Matrix<double> matrix = DenseMatrix.OfArray(new double[,]
  13.                     {
  14.                         {-0.5, 1.5, -1.5, 0.5},
  15.                         {1, -2.5, 2, -0.5},
  16.                         {-0.5, 0, 0.5, 0},
  17.                         {0, 1, 0, 0}
  18.                     });
  19.                     Matrix<double> Xmatrix = DenseMatrix.OfArray(new double[,]
  20.                     {
  21.                         {points.Keys.ElementAt(x - 3)},
  22.                         {points.Keys.ElementAt(x - 2)},
  23.                         {points.Keys.ElementAt(x - 1)},
  24.                         {points.Keys.ElementAt(x)}
  25.                     });
  26.                     Matrix<double> Ymatrix = DenseMatrix.OfArray(new double[,]
  27.                     {
  28.                         {points.Values.ElementAt(x - 3)},
  29.                         {points.Values.ElementAt(x - 2)},
  30.                         {points.Values.ElementAt(x - 1)},
  31.                         {points.Values.ElementAt(x)}
  32.                     });
  33.                     Matrix<double> XResultMatrix = Tmatrix * matrix * Xmatrix;
  34.                     Matrix<double> YResultMatrix = Tmatrix * matrix * Ymatrix;
  35.                     if (!newPoints.ContainsKey(XResultMatrix[0, 0]))
  36.                     {
  37.                         newPoints.Add(XResultMatrix[0, 0], YResultMatrix[0, 0]);
  38.                     }
  39.                 }
  40.             }
  41.             DrawPoligonalLine(newPoints, System.Windows.Media.Brushes.BlueViolet);
  42.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement