Public
Edited
May 22
Insert cell
Insert cell
Insert cell
wallToNewell = 123.75
Insert cell
// wall to newell minus half newell
newellToNewell = wallToNewell - 2.25
Insert cell
// minus the mid newell
spaceAvailable = newellToNewell - 4.5
Insert cell
spindleSize = 5 / 8
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// 1. buffer
// 2. (spindle + gap) x leftSpindleCt
// 3. buffer
// 4. 4.5" (newell)
// 5. buffer
// 6. (spindle + gap) x (spindleCt - leftSpindleCt)
// 7. buffer
// 8. right newell
Insert cell
leftSpindleCt = spindlesCt - rightSpindleCt
Insert cell
// everything but the gap between spindles and newells
spaceUsed = spindleSize * spindlesCt + gapSize * gapCt
Insert cell
halfNewell = ({ type: "newell", left: -2.25, right: 0 })
Insert cell
Insert cell
Insert cell
Insert cell
rightNewell = ({
type: "newell",
left: newellToNewell,
right: newellToNewell + 4.5
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
asFraction = (input) => {
let num, denom, whole;

if (Array.isArray(input)) {
num = input[0];
denom = input[1];
whole = Math.floor(num / denom);
num -= whole * denom;
} else {
const decimal = input % 1;
if (decimal === 0) return input;

whole = Math.floor(input);
const decStr = ("" + decimal).match(/(?<=\.)\d*/);

num = parseInt(decStr[0]);
denom = 10 ** decStr[0].length;
}

// determine last common factor and reduce the fraction
let lcf = 1;
while (lcf < Math.max(num, denom)) {
lcf++;
if (num % lcf === 0 && denom % lcf === 0) {
num = num / lcf;
denom = denom / lcf;
lcf = 1;
}
}
return `${whole}${num !== 0 ? ` ${num}/${denom}` : ""}`;
}
Insert cell
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