You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit eaa4fc9
Browse filesBrowse the repository at this point in the historyBrowse files
Automatically draw a monotonic curve when using Hermite cubic spline interpolation on a scatter plot with monotonic plot data. Fixed issue core-plot#193.
/** @brief Compute the control points using a hermite cubic spline. Taken from https://en.wikipedia.org/wiki/Cubic_Hermite_spline (see representations).
1322
+
/** @brief Compute the control points using a hermite cubic spline.
1323
+
*
1324
+
* If the view points are monotonically increasing or decreasing in both @par{x} and @par{y},
1325
+
* the smoothed curve will be also.
1326
+
*
1322
1327
* @param points A pointer to the array which should hold the first control points.
1323
1328
* @param points2 A pointer to the array which should hold the second control points.
1324
1329
* @param viewPoints A pointer to the array which holds all view points for which the interpolation should be calculated.
1325
1330
* @param indexRange The range in which the interpolation should occur.
1326
-
* @warning The indexRange must be valid for all passed arrays otherwise this method crashes.
1331
+
* @warning The @par{indexRange} must be valid for all passed arrays otherwise this method crashes.
// See https://en.wikipedia.org/wiki/Cubic_Hermite_spline and https://en.m.wikipedia.org/wiki/Monotone_cubic_interpolation for a discussion of algorithms used.
1330
1336
if ( indexRange.length >= 2 ) {
1331
-
NSUInteger startIndex = indexRange.location;
1332
-
NSUInteger numberOfPoints = NSMaxRange(indexRange) - 1; // last accessible element in view points
1333
-
for ( NSUInteger index = indexRange.location; index <= numberOfPoints; index++ ) {
// We calculated the lhs & rhs control point. the rhs control point is the first control point for the curve to the next point. the lhs control point is the second control point for the curve to the current point.
// We calculated the lhs & rhs control point. The rhs control point is the first control point for the curve to the next point. The lhs control point is the second control point for the curve to the current point.
1363
1390
1364
1391
points2[index] = lhsControlPoint;
1365
-
if ( index + 1 <= numberOfPoints ) {
1392
+
if ( index + 1 <= lastIndex ) {
1366
1393
points[index + 1] = rhsControlPoint;
1367
1394
}
1368
1395
}
1369
1396
}
1370
1397
}
1371
1398
1399
+
/** @brief Determine whether the plot points form a monotonic series.
1400
+
* @param viewPoints A pointer to the array which holds all view points for which the interpolation should be calculated.
1401
+
* @param indexRange The range in which the interpolation should occur.
1402
+
* @return Returns @YES if the viewpoints are monotonically increasing or decreasing in both @par{x} and @par{y}.
1403
+
* @warning The @par{indexRange} must be valid for all passed arrays otherwise this method crashes.
0 commit comments