Improve brush
This commit is contained in:
parent
b3d9229af5
commit
780388d74b
5 changed files with 76 additions and 66 deletions
|
|
@ -1,28 +0,0 @@
|
|||
import { vec2 } from 'gl-matrix';
|
||||
|
||||
export const catmullRomInterpolation = (
|
||||
p0: vec2,
|
||||
p1: vec2,
|
||||
p2: vec2,
|
||||
p3: vec2,
|
||||
t: number
|
||||
): vec2 => {
|
||||
const t2 = t * t;
|
||||
const t3 = t2 * t;
|
||||
|
||||
const x =
|
||||
0.5 *
|
||||
(2 * p1[0] +
|
||||
(-p0[0] + p2[0]) * t +
|
||||
(2 * p0[0] - 5 * p1[0] + 4 * p2[0] - p3[0]) * t2 +
|
||||
(-p0[0] + 3 * p1[0] - 3 * p2[0] + p3[0]) * t3);
|
||||
|
||||
const y =
|
||||
0.5 *
|
||||
(2 * p1[1] +
|
||||
(-p0[1] + p2[1]) * t +
|
||||
(2 * p0[1] - 5 * p1[1] + 4 * p2[1] - p3[1]) * t2 +
|
||||
(-p0[1] + 3 * p1[1] - 3 * p2[1] + p3[1]) * t3);
|
||||
|
||||
return [x, y];
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue