daily pastebin goal
50%
SHARE
TWEET

Untitled

a guest Feb 19th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $fn=30;
  2.  
  3. function calcScale(scaleFactors, count, iteration) =
  4.     scaleFactors[0] +
  5.     (( scaleFactors[1]-scaleFactors[0]))*iteration/count;
  6.    
  7. module hullSweep(steps, rotation, offsetTo, scaleFactors)
  8. {
  9.     for ( i= [0:steps-2] )
  10.     {
  11.         scaleAmt1 = calcScale(scaleFactors, steps, i);
  12.         scaleAmt2 = calcScale(scaleFactors, steps, i+1);
  13.  
  14.         hull()
  15.         {
  16.             rotate(rotation*i)
  17.             translate(offsetTo*i)
  18.             scale([scaleAmt1,scaleAmt1,scaleAmt1])
  19.             children();
  20.  
  21.             rotate(rotation*(i+1))
  22.             translate(offsetTo*(i+1))
  23.             scale([scaleAmt2,scaleAmt2,scaleAmt2])
  24.             children();
  25.         }
  26.     }
  27. }
  28.  
  29. // Examples
  30. // Horn #1
  31. hullSweep(40,[0,0,4],[1,1,1.5],[5,0])
  32. scale([1,2,1])
  33. sphere(1);
  34.  
  35. // Horn #2
  36. translate([50,0,0])
  37. hullSweep(20,[0,0,4],[1,1,1.5],[5,0])
  38. scale([1,2,1])
  39. sphere(1);
  40.  
  41. // Short horn
  42. translate([100,0,0])
  43. hullSweep(40,[0,0,3],[1,1,1.5],[10,0])
  44. union()
  45. {
  46.    sphere(1);
  47.    translate([4,0,0])
  48.    sphere(1.5);
  49. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top