Improve brush

This commit is contained in:
Andras Schmelczer 2023-05-01 13:01:12 +01:00
parent b3d9229af5
commit 780388d74b
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
5 changed files with 76 additions and 66 deletions

View file

@ -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];
};