-
Notifications
You must be signed in to change notification settings - Fork 5
Project: Threaded Rod
pentacular edited this page Aug 8, 2019
·
4 revisions
const Thread = ({ radius = 1, height = 1, threadHeight = 1, sides = 16 } = {}) => {
const X = 0;
const Y = 1;
const Z = 2;
const thread =
lathe({ loops: height / threadHeight, loopOffset: threadHeight, sides },
Triangle()
.scale(threadHeight)
.rotateZ(90)
.move(0, radius));
const [min, max] = thread.measureBoundingBox();
return intersection(Cube.fromCorners([0, min[Y], min[Z]],
[height, max[Y], max[Z]]),
thread)
.rotateY(-90)
.center();
}
const ThreadedRod = ({ radius = 1, height = 1, threadHeight = 1, sides = 16, play = 0 } = {}) => {
if (play !== 0) {
return assemble(ThreadedRod({ radius, height, threadHeight, sides }).drop(),
ThreadedRod({ radius: radius - play, height, threadHeight, sides }));
} else {
return assemble(Thread({ radius, height, threadHeight, sides }),
Cylinder({ radius, height, sides }));
}
}
assemble(
Cube(20).as('cube'),
ThreadedRod({ radius: 5, height: 20, sides: 32 }).as('rod'))
.withWireframe();