|
@@ -4,10 +4,6 @@ const jab2hue = ([, a, b]) => rad2deg * Math.atan2(b, a);
|
|
|
const rgb2hue = rgb => d3.hsl(d3.rgb(...rgb)).h || 0;
|
|
|
const jab2lit = ([j]) => j;
|
|
|
const rgb2lit = rgb => d3.hsl(d3.rgb(...rgb)).l || 0;
|
|
|
-const hex2rgb = hex => {
|
|
|
- const { r, g, b } = d3.color(hex);
|
|
|
- return [r, g, b];
|
|
|
-};
|
|
|
|
|
|
const buildVectorData = (vector, toHue, toLightness, toHex) => {
|
|
|
const sqMag = vectorDot(vector, vector);
|
|
@@ -19,11 +15,14 @@ const buildVectorData = (vector, toHue, toLightness, toHex) => {
|
|
|
return { vector, sqMag, mag, unit, hue, lightness, hex };
|
|
|
};
|
|
|
|
|
|
-const buildClusterData = (size, inertia, mu1, mu2, mu3, nu1, nu2, nu3, toHue, toLightness, toHex) => ({
|
|
|
- size, inertia,
|
|
|
- mu: buildVectorData([mu1, mu2, mu3], toHue, toLightness, toHex),
|
|
|
- nu: [nu1, nu2, nu3],
|
|
|
-});
|
|
|
+const buildClusterData = (size, inertia, mu1, mu2, mu3, nu1, nu2, nu3, toHue, toLightness, toHex) => {
|
|
|
+ const mu = buildVectorData([mu1, mu2, mu3], toHue, toLightness, toHex);
|
|
|
+ const nu = [nu1, nu2, nu3];
|
|
|
+ return {
|
|
|
+ size, inertia, mu, nu,
|
|
|
+ muNuAngle: rad2deg * Math.acos(vectorDot(mu.unit, nu) / vectorMag(nu)),
|
|
|
+ };
|
|
|
+};
|
|
|
|
|
|
const buildPokemonData = ([name, size, ...values]) => ({
|
|
|
name,
|