Skip to content

Commit

Permalink
perf(math): replace mixBilinear() w/ inline impl
Browse files Browse the repository at this point in the history
- new impl ~1.7x faster
  • Loading branch information
postspectacular committed Mar 16, 2021
1 parent aa71eb7 commit bb16dc5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/math/src/mix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ export const mix: FnN3 = (a, b, t) => a + (b - a) * t;
* @param u - 1st interpolation factor
* @param v - 2nd interpolation factor
*/
export const mixBilinear: FnN6 = (a, b, c, d, u, v) =>
mix(mix(a, b, u), mix(c, d, u), v);
export const mixBilinear: FnN6 = (a, b, c, d, u, v) => {
const iu = 1 - u;
const iv = 1 - v;
return a * iu * iv + b * u * iv + c * iu * v + d * u * v;
};

export const mixQuadratic: FnN4 = (a, b, c, t) => {
const s = 1 - t;
Expand Down

0 comments on commit bb16dc5

Please sign in to comment.