Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module coilsBase(radius, height, size)
- {
- render(1) difference() {
- cylinder(r=radius, h=height, $fn=150);
- cylinder(r=radius-size, h=height, $fn=150);
- }
- }
- module coil(width, botLength, topLength, height, extrudeDeep, extrudeWidth)
- {
- //main polyhedron
- points = [
- //bottom side
- [0, 0, 0], //down-left
- [width, 0, 0], //down-right
- [width, botLength, 0], //up-right
- [0, botLength, 0], //up-left
- //top side
- [0, 0, height], //down-left
- [width, 0, height], //down-right
- [width, topLength, height], //up-right
- [0, topLength, height] //up-left
- ];
- faces = [
- [0, 1, 2, 3], //down face
- [1, 0, 4, 5], //back face
- [0, 3, 7, 4], //left face
- [3, 2, 6, 7], //front face
- [2, 1, 5, 6], //right face
- [5, 4, 7, 6] //top face
- ];
- //extrude cubes
- frontFaceLenght = sqrt(pow(height,2) + pow(botLength-topLength,2));
- extBackBox = [width-(2*extrudeWidth), extrudeDeep, height];
- extTopBox = [width-(2*extrudeWidth), topLength-extrudeDeep, extrudeDeep];
- extFrontBox = [width-(2*extrudeWidth), frontFaceLenght, extrudeDeep];
- extFrontBoxRotation = atan2(botLength-topLength, height)+90;
- extBotBox = [width-(2*extrudeWidth), botLength-extrudeDeep, extrudeDeep];
- render(1) difference() {
- polyhedron(points, faces, 10);
- union() {
- translate([extrudeWidth, 0, 0])
- cube(extBackBox);
- translate([extrudeWidth, extrudeDeep, height-extrudeDeep])
- cube(extTopBox);
- translate([extrudeWidth, botLength, 0])
- rotate(extFrontBoxRotation, [1,0,0])
- cube(extFrontBox);
- translate([extrudeWidth, extrudeDeep, 0])
- cube(extBotBox);
- }
- }
- }
- color("Silver") coilsBase(radius=10, height=2, size=3);
- color("Gold") translate([0, 0, 15]) coil(width=3, botLength=5, topLength=4, height=3, extrudeDeep=0.5, extrudeWidth=0.5);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement