##// END OF EJS Templates
Fixed a bug with last two control points calculation
Marek Rosa -
r429:cbe57d7d97d6
parent child
Show More
@@ -27,10 +27,20 SplineWidget::SplineWidget(QWidget *parent)
27 // series->add(QPointF(750, 180));
27 // series->add(QPointF(750, 180));
28 // series->add(QPointF(800, 170));
28 // series->add(QPointF(800, 170));
29
29
30 qsrand(time(NULL));
30 // qsrand(time(NULL));
31 for (int i = 0; i < 100; i++)
31 // for (int i = 0; i < 100; i++)
32 // {
33 // series->add(QPointF(i*7, qrand()%600));
34 // }
35 int k = 10;
36 for (int i = 0; i < 25; i++)
32 {
37 {
33 series->add(QPointF(i*7, qrand()%600));
38 if (k > 60)
39 {
40 k = 10;
41 }
42 series->add(QPointF(i*50, k));
43 k +=10;
34 }
44 }
35
45
36 series->calculateControlPoints();
46 series->calculateControlPoints();
@@ -55,7 +55,7 void QSplineSeries::calculateControlPoints()
55 rhs.append(m_x[0] + 2 * m_x[1]);
55 rhs.append(m_x[0] + 2 * m_x[1]);
56
56
57 // Set right hand side X values
57 // Set right hand side X values
58 for (int i = 1; i < m_x.size() - 1; ++i)
58 for (int i = 1; i < n - 1; ++i)
59 rhs.append(4 * m_x[i] + 2 * m_x[i + 1]);
59 rhs.append(4 * m_x[i] + 2 * m_x[i + 1]);
60
60
61 rhs.append((8 * m_x[n - 1] + m_x[n]) / 2.0);
61 rhs.append((8 * m_x[n - 1] + m_x[n]) / 2.0);
@@ -64,7 +64,7 void QSplineSeries::calculateControlPoints()
64 rhs[0] = m_y[0] + 2 * m_y[1];
64 rhs[0] = m_y[0] + 2 * m_y[1];
65
65
66 // Set right hand side Y values
66 // Set right hand side Y values
67 for (int i = 1; i < m_y.size() - 1; ++i)
67 for (int i = 1; i < n - 1; ++i)
68 rhs[i] = 4 * m_y[i] + 2 * m_y[i + 1];
68 rhs[i] = 4 * m_y[i] + 2 * m_y[i + 1];
69
69
70 rhs[n - 1] = (8 * m_y[n - 1] + m_y[n]) / 2.0;
70 rhs[n - 1] = (8 * m_y[n - 1] + m_y[n]) / 2.0;
@@ -74,7 +74,7 void QSplineSeries::calculateControlPoints()
74 // Fill output arrays.
74 // Fill output arrays.
75 // firstControlPoints = new Point[n];
75 // firstControlPoints = new Point[n];
76 // secondControlPoints = new Point[n];
76 // secondControlPoints = new Point[n];
77 for (int i = 0; i < m_x.size(); ++i)
77 for (int i = 0; i < n; ++i)
78 {
78 {
79 // First control point
79 // First control point
80 m_controlPoints.append(QPointF(x[i], y[i]));
80 m_controlPoints.append(QPointF(x[i], y[i]));
General Comments 0
You need to be logged in to leave comments. Login now