* @param {Number} t the value (0-1) at which to split * @return {Cubic} the second part of the curve * * splits the cubic into two parts at a point 't' along the curve. * this cubic keeps its start point and its end point becomes the * point at 't'. the '
(t)
| 365 | * point at 't'. the 'end half is returned. |
| 366 | */ |
| 367 | split(t) { |
| 368 | const m1 = Vector.lerp(this.p0, this.c0, t); |
| 369 | const m2 = Vector.lerp(this.c0, this.c1, t); |
| 370 | const mm1 = Vector.lerp(m1, m2, t); |
| 371 | |
| 372 | this.c1 = Vector.lerp(this.c1, this.p1, t); |
| 373 | this.c0 = Vector.lerp(m2, this.c1, t); |
| 374 | const pt = Vector.lerp(mm1, this.c0, t); |
| 375 | const part1 = new Cubic(this.p0, m1, mm1, pt); |
| 376 | this.p0 = pt; |
| 377 | return part1; |
| 378 | } |
| 379 | |
| 380 | /** |
| 381 | * @return {Cubic[]} the non-inflecting pieces of this cubic |
no test coverage detected