Swiftpack.co - boeders/CubicSplineSwift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by boeders.
boeders/CubicSplineSwift 1.1.0
A Constrained Cubic Spline implementation in Swift
⭐️ 0
🕓 2 years ago
.package(url: "https://github.com/boeders/CubicSplineSwift.git", from: "1.1.0")

Build

CubicSplineSwift

An implementation of an constrained cubic spline that should eliminate over and undershoot when handling charts while maintaining a smooth curve.

Installation

You can use CubicSplineSwift through SPM.

Example Data

X 0 1 2 3 4 5 6 7 8 9 10 11 12
Y 300 350 370 450 600 480 400 500 400 350 400 600 450

The data was normalized to values between 0 and 1 before creating the spline. image

Usage

Initialize the ConstrainedCubicSpline with a list of at least 3 Points. Alternatively use lists with x and y coordinates which need to be the same length and have at least 3 values each. Then you can call createSpline which will return an array of points that span the data from start to finish. This will result in x values from 0.00, 0.01 to 0.99, 1.00 if 101 values would be requested.

Source

calculation source: https://pages.uoregon.edu/dgavin/software/spline.pdf

License

CubicSplineSwift is available under MIT License.

GitHub

link
Stars: 0
Last commit: 2 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

A ConstrainedCubicSpline implementation
2 years ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics