Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ryohey/smooth.swift

Interpolate and smooth the array of numbers. Heavily inspired from Smooth.js.
https://github.com/ryohey/smooth.swift

Last synced: about 1 month ago
JSON representation

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

Awesome Lists containing this project

README

        

# Smooth.swift

[![CocoaPods](https://img.shields.io/cocoapods/v/Smooth.svg)](https://cocoapods.org/pods/Smooth)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)

Turn arrays into smooth functions.
Interpolation functions are ported from [Smooth.js](https://github.com/osuushi/Smooth.js/).

## Installation

### CocoaPods

```ruby
pod 'Smooth'
```

### Carthage

```
github "ryohey/Smooth.swift"
```

## Input

![2018-07-28 13 22 52](https://user-images.githubusercontent.com/5355966/43353080-ec9d696c-9269-11e8-81ad-13a1478d1b5c.png)

## Interpolation

![2018-07-28 13 22 23](https://user-images.githubusercontent.com/5355966/43353082-ece9553e-9269-11e8-9475-ea206b84f79c.png)

## Smoothing

![2018-07-28 13 22 33](https://user-images.githubusercontent.com/5355966/43353081-ecc4c2e6-9269-11e8-9820-dbdb1101e7d6.png)

## 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.

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

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

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