//import { Bezier } from "./bezierjs/src/bezier.js"; function map (a, a_min, a_max, b_min, b_max) { return b_min + ((b_max - b_min) / (a_max - a_min)) * (a - a_min); } function fmt (x) { return x.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2, useGrouping: false }); } function duty_cycle_map (x) { //const out = Math.log10(x + 1) * 50; //const out = x; x = x / 100; //let y = 1 - Math.pow(1 - x, 5); //let y = x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2; //let y = Math.sqrt(1 - Math.pow(x - 1, 2)); //let y = x < 0.5 ? 2 * x * x : 1 - Math.pow(-2 * x + 2, 2) / 2; let y = Math.sin((x * Math.PI) / 2); y = map(y, 0, 1, 47, 100); return y } function freq_map (x) { x = x / 100; //let y = 1 - (1 - x) * (1 - x); //let y = x === 1 ? 1 : 1 - Math.pow(2, -10 * x); let y; if (x < 0.05) { x = map(x, 0, 0.05, 0, 1); y = -(Math.cos(Math.PI * x) - 1) / 2; y = map(y, 0, 1, 15000, 19000); } else if (x < 0.5) { x = map(x, 0, 0.5, 0, 1); y = -(Math.cos(Math.PI * x) - 1) / 2; y = map(y, 0, 1, 20000, 50000); } else { y = 100000; } return y; } function generate_command() { return [...Array(100).keys()].map((x) => x + 1).map((x) => "D" + (x - 1) + " " + fmt(duty_cycle_map(x)) + " " + fmt(freq_map(x))).join(""); } //console.log("M" + vals + "R");