Maker & printing · Test cube 21
Spaghetti
Loose wavy strands crossing the surface: a print failure, on purpose.
Layer lines as a texture? Finally, someone gets it.
- Prints well with a 0.4 mm nozzle.
25 mm, with your size and depth. Prints upright, no supports. About 4 MB.
- Depth as written1.1 mm
- Narrowest partabout 2 mm
- Smallest size, 0.4 mm nozzle× 0.60
Good for
Inside jokes and gifts for anyone who has printed spaghetti.
Print notes
- Depth 0.4 to 1.5 mm for a 0.4 mm nozzle (as written: 1.1 mm).
- Best on walls, printed upright. On a flat top, use thin layers (0.12 mm or less).
- Fade it out over the bottom 3 mm so the first layers are flat and stick to the plate.
- Not printed yet: these notes come from the geometry. The test cube will tell us more.
The formula
The real code this page runs: give it a point (U mm across, V mm up) and it returns the height there, in mm. Push the surface out by that much and the texture is real geometry.
function spaghetti(U: number, V: number, amp = 1.1, n = 7) {
let h = 0;
for (let k = 0; k < n; k++) {
const a = 3 + 2 * rnd(k, 1, 1);
const b = 5 + 3 * rnd(k, 2, 1);
const c = rnd(k, 3, 1) * 40;
const y = c + 6 * Math.sin(U / a + k) + 4 * Math.sin((U / b) * 1.7 + 2 * k);
const dv = Math.abs(frac((V - y) / 40 + 0.5) - 0.5) * 40;
h = Math.max(h, amp * dome((dv / 1.0) ** 2));
}
return h;
}The helpers it uses (frac, dome, clamp, rnd)
/** The fractional part, 0..1. */
function frac(x: number) {
return x - Math.floor(x);
}/** A round bump: 1 in the middle (r2 = 0), 0 at the edge (r2 = 1). */
function dome(r2: number) {
return Math.sqrt(clamp(1 - r2, 0, 1));
}function clamp(x: number, lo: number, hi: number) {
return Math.min(Math.max(x, lo), hi);
}/** A repeatable random number 0..1 for a cell (no Math.random: the same texture every time). */
function rnd(a: number, b: number, k = 0) {
const x = Math.sin(a * 127.1 + b * 311.7 + k * 74.7) * 43758.5453;
return x - Math.floor(x);
}Printed
Test cube 21 is waiting for the printer. Its photo goes here.