├── .gitignore
├── package.json
├── index.js
├── README.md
└── LICENSE
/.gitignore:
--------------------------------------------------------------------------------
1 | test*
2 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bezier-curve",
3 | "version": "1.0.0",
4 | "description": "Bezier curve interpolation",
5 | "author": "thibauts",
6 | "license": "MIT",
7 | "main": "index.js",
8 | "scripts": {
9 | "test": "echo \"Error: no test specified\" && exit 1"
10 | },
11 | "repository": {
12 | "type": "git",
13 | "url": "git://github.com/thibauts/bezier-curve.git"
14 | },
15 | "keywords": [
16 | "bezier",
17 | "curve",
18 | "interpolation"
19 | ]
20 | }
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 |
2 |
3 | function interpolate(t, p) {
4 | var order = p.length - 1; // curve order is number of control point - 1
5 | var d = p[0].length; // control point dimensionality
6 |
7 | // create a source vector array copy that will be
8 | // used to store intermediate results
9 | var v = p.map(function(point) {
10 | return point.slice();
11 | });
12 |
13 | // for each order reduce the control point array by updating
14 | // each control point with its linear interpolation to the next
15 | for(var i=order; i>0; i--) {
16 | for(var j=0; j
33 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Thibaut Séguy
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------