/Smooth.swift

Interpolate and smooth the array of numbers. Heavily inspired from Smooth.js.

Primary LanguageSwiftMIT LicenseMIT

Smooth.swift

CocoaPods Carthage compatible

Turn arrays into smooth functions. Interpolation functions are ported from Smooth.js.

Installation

CocoaPods

pod 'Smooth'

Carthage

github "ryohey/Smooth.swift"

Input

2018-07-28 13 22 52

Interpolation

2018-07-28 13 22 23

Smoothing

2018-07-28 13 22 33

Use with SceneKit

In order to make as little dependence as possible, Smooth.swift does not use SceneKit, but in order to make it easy to use it, a VectorType is added. Since SCNVector3 and SCNVector4 are concrete types already implementing VectorType, you can use VectorInterpolator by simply specifying it with extension.

extension SCNVector3: Vector3, VectorType {}
extension SCNVector4: Vector4, VectorType {}

VectorInterpolator is generated by providing Interpolator which interpolates for each element.

VectorInterpolator(points: [SCNVector3(0.1, 0.2, 0.5), SCNVector3(0.5, 0.6, 0.1)], interpolatorCreator: { LinearInterpolator(points: $0).interpolate })