Public
Edited
Dec 14, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
movesOnly = lowered
.filter((ir) => ir.op === "move")
.map((ir) => ({ x: ir.args.x, y: ir.args.y, z: ir.args.z }))
Insert cell
Plot.dot(movesOnly, {
x: "x",
y: "y"
}).plot()
Insert cell
Insert cell
Plot.plot({
inset: 10,
grid: true,
x: { label: "x position (in)", domain: [-5.5, -4.5], line: true },
y: { label: "y position (in)", domain: [-0.5, 0.5], line: true },
marks: [
Plot.dot(movesOnly, {
x: "x",
y: "y"
})
]
})
Insert cell
Plot.plot({
inset: 10,
grid: true,
x: { label: "x position (in)", domain: [-6, 6], line: true },
y: { label: "z position (in)", domain: [-2, 2], line: true },
marks: [
Plot.dot(movesOnly, {
x: "x",
y: "z"
})
]
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
roundToMultiple(12, 5)
Insert cell
Insert cell
Insert cell
// Bin
d3.bin().value((xyzi) => xyzi.z)(spoonMoves)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
triples = beginningMoves.map((pt, idx, arr) => {
let before = idx > 0 ? arr[idx] : null;
let after = idx < arr.length ? arr[idx] : null;
return [before, pt, after];
})
Insert cell
function convolve(signal, filter) {
let outputLen = signal.length * 2;
let newSig = new Array(outputLen);
let sum = 0;
let signalMax = Math.max(Math.max(...signal), 1);
let filterMax = Math.max(Math.max(...filter), 1);
let normSignal = signal.map((e) => e / signalMax);
let normFilter = filter.map((e) => e / filterMax);
for (let i = 0; i < outputLen; i++) {
for (let j = Math.max(0, i - signal.length); j <= i; j++) {
let jInBounds = j < signal.length && i - j < filter.length;
if (jInBounds) {
sum += signal[j] * normFilter[i - j];
}
}
newSig[i] = sum;
sum = 0;
}
let begin = Math.floor(outputLen * 0.25);
let end = Math.floor(outputLen * 0.75);
return newSig.slice(begin, end);
}
Insert cell
xConvX = convolve(
beginningMoves.map((m) => m.x),
beginningMoves.map((m) => m.x)
)
Insert cell
squareWave = {
let len = 200;
let low = new Array(75).fill(0);
let high = new Array(50).fill(50);
return low.concat(high).concat(low);
}
Insert cell
sawToothWave = {
let len = 200;
let low = new Array(75).fill(0);
let high = new Array(50).fill(0).map((_, i) => -i + 50);
return low.concat(high).concat(low);
}
Insert cell
sawToothWave.slice(90, 110)
Insert cell
Insert cell
convolve(squareWave, sawToothWave).slice(140, 175)
Insert cell
Plot.plot({
inset: 10,
grid: true,
x: { label: "x position (in)", line: true },
y: { label: "z position (in)", line: true },
marks: [
Plot.lineY(squareWave),
Plot.lineY(sawToothWave),
Plot.lineY(convolve(squareWave, sawToothWave).map((e) => e / 25))
]
})
Insert cell
Insert cell
beginningMoves
Insert cell
Insert cell
{
let beginX = beginningMoves.map((m) => m.x);
let beginY = beginningMoves.map((m) => m.y);
let derivX = derivative(beginX);
let derivY = derivative(beginY);
return Plot.plot({
title: "Derivative of X and Y with respect to instruction",
width: 1280,
inset: 10,
grid: true,
x: { label: "instruction #", line: true },
y: { label: "velocity?? (in/s)", line: true },
marks: [
// Plot.lineY(beginX),
// Plot.lineY(beginY),
// Plot.lineY(convXY),
Plot.lineY(derivX)
//Plot.lineY(derivY)
]
});
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more