Skip to content

Instantly share code, notes, and snippets.

@adamchalmers
Created June 21, 2024 22:08
Show Gist options
  • Save adamchalmers/f1a89627d7343ae1d713761fb7f35f1e to your computer and use it in GitHub Desktop.
Save adamchalmers/f1a89627d7343ae1d713761fb7f35f1e to your computer and use it in GitHub Desktop.
// base radius
const r = 50
// layer height
const h = 10
// taper factor [0 - 1)
const t = 0.005
fn layer = (i) => {
return startSketchOn({
plane: {
origin: { x: 0, y: 0, z: i * h },
x_axis: { x: 1, y: 0, z: 0 },
y_axis: { x: 0, y: 1, z: 0 },
z_axis: { x: 0, y: 0, z: 1 }
}
})
|> circle([0, 0], r * abs(1 - (t * i)) * (5 + cos(i / 8)), %, 'tag1')
|> extrude(h, %)
|> fillet({
radius: h / 2.01,
tags: ["tag1", getOppositeEdge("tag1", %)]
}, %)
}
// I want loops 😩
fn ten_layers = (n) => {
const start = 10 * n
layer(start)
layer(start + 1)
layer(start + 2)
layer(start + 3)
layer(start + 4)
layer(start + 5)
layer(start + 6)
layer(start + 7)
layer(start + 8)
layer(start + 9)
}
ten_layers(0)
ten_layers(1)
ten_layers(2)
ten_layers(3)
ten_layers(4)
ten_layers(5)
ten_layers(6)
ten_layers(7)
ten_layers(8)
ten_layers(9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment