3D ontwerp SCAD – Pieslice (taartpunt)
Screens: Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
// PieTest /** * @author: Marcel Jira * This module generates a pie slice in OpenSCAD. It is inspired by the * [dotscad](https://github.com/dotscad/dotscad) * project but uses a different approach. * I cannot say if this approach is worse or better. * @param float radius Radius of the pie * @param float angle Angle (size) of the pie to slice * @param float height Height (thickness) of the pie * @param float spin Angle to spin the slice on the Z axis */ module pie(radius, angle, height, spin=0) { // calculations ang = angle % 360; absAng = abs(ang); halfAng = absAng % 180; negAng = min(ang, 0); // submodules module pieCube() { translate([-radius - 1, 0, -1]) { cube([2*(radius + 1), radius + 1, height + 2]); } } module rotPieCube() { rotate([0, 0, halfAng]) { pieCube(); } } if (angle != 0) { if (ang == 0) { cylinder(r=radius, h=height); } else { rotate([0, 0, spin + negAng]) { intersection() { cylinder(r=radius, h=height); if (absAng < 180) { difference() { pieCube(); rotPieCube(); } } else { union() { pieCube(); rotPieCube(); } } } } } } } /** * When used as a module (statement "use <pie.scad>") the example below will not * render. If you run this file alone, it will :) */ pie(radius=10, angle=-260, height=5, spin = 0); pie(radius=15, angle=25, height = 10, spin = 30); |
Wat heb je nodig? 1) OpenSCADÂ software Download @ Github.com