Spielstein.scad 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* [OpenSCAD] */
  2. $fn=90;
  3. /* [Spielstein] */
  4. // Form, Größe, Füllung
  5. Form = 0; // [0:Eckig, 1:Rund]
  6. Size = 1; // [0:Klein, 1:Groß]
  7. Hut = 0; // [0:Nein, 1:Ja]
  8. /* [Spielstein] */
  9. // Loch für Magnet im Fuß
  10. Magnet = 0; // [0:Nein, 1:Ja]
  11. /* [Hidden] */
  12. module piece(f, s, h) {
  13. }
  14. module fuss() {
  15. hull() {
  16. translate([0,0,1]) rotate_extrude() translate([9,0]) circle(d=2);
  17. cylinder(d=20, h=0.01, center=false);
  18. }
  19. cylinder(d=6, h=10);
  20. }
  21. module wuerfel() {
  22. // https://reprap.org/forum/read.php?247,458171,458591#msg-458591
  23. w=90-acos(sqrt(2/3)); // Winkel der Raumdiagonale
  24. scale(20/sqrt(3)) for (i=[0:60:360]) {
  25. rotate([0, w, i]) translate([-sqrt(2)/2, 0, 0.5]) rotate([0, 0, 45]) cube(1, center=true);
  26. }
  27. }
  28. module hut() {
  29. cylinder(d=8, h=1);
  30. cylinder(d=5, h=4);
  31. }
  32. module eckig(hut) {
  33. fuss();
  34. wuerfel();
  35. if (hut==1) translate([0,0,18]) scale(1/3) wuerfel();
  36. }
  37. module rund(hut) {
  38. fuss();
  39. translate([0,0,10]) sphere(d=20);
  40. if (hut==1) translate([0,0,21]) scale(1/3) sphere(d=20);
  41. }
  42. ////////////////////////////////////////////////////////////////////////////////////////////
  43. difference() {
  44. union() {
  45. if (Form==0) {
  46. if (Size==0) {
  47. scale(1/sqrt(2)) eckig(Hut);
  48. }
  49. else {
  50. eckig(Hut);
  51. }
  52. }
  53. else {
  54. if (Size==0) {
  55. scale(1/sqrt(2)) rund(Hut);
  56. }
  57. else {
  58. rund(Hut);
  59. }
  60. }
  61. }
  62. if (Magnet==1) {
  63. translate([0,0,-0.01]) cylinder(d=3, h=5.5);
  64. }
  65. }