Advertisement
bboett

kiefer.scad

May 22nd, 2020
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. use <../iaito/naca/files/Naca_sweep.scad>
  2. kieferDraw(b =40,l = 70,lw=10, d=2);
  3. translate([0,00,5])rotate([0,180,0])kieferDraw(b =50,l = 70,lw=10, d=2);
  4.  
  5. function baseForm(x, b, l) = (b!= 0)? 4*l/(b*b) *x*x - l:0;
  6. function curveAngle(l, y0, ueber, lw,hprim) = (l+y0 <= ueber)? 105-2*lw - atan((ueber -y0)/hprim):(y0 == 0)? 0:-atan(y0/hprim);
  7.  
  8. function roundPoint2D(pt,rad, res = 3,above = true, left = false) =
  9. [
  10. if(above == true)
  11. for(n = [((left)? res:0):((left)? -1:1):((left)? 0:res)])
  12. let (w = 180/res*n)
  13. [pt[0]+rad*cos(w), pt[1]+rad*sin(w)]
  14. else
  15. for(n = [((!left)? res:0):((!left)? -1:1):((!left)? 0:res)])
  16. let (w = 180+180/res*n)
  17. [pt[0]+rad*cos(w), pt[1]+rad*sin(w)]
  18. ];
  19.  
  20. function transvCut2D(x,z,d=1,res=8) =
  21. [
  22. [0,z+x+d],
  23. each(roundPoint2D([-x,z],d,res = res, left=true, above=true)),
  24. each(roundPoint2D([0,z+x],d,res =res, left=false,above = false)),
  25. each(roundPoint2D([x,z],d,res, left=true,above = true))
  26. ];
  27.  
  28. function trajectory(b,l,lw=10, d=2, curve)= // prepare data for sweep()
  29. [
  30. //let(curve = sqrt(l*l+ b*b/4)) //fail?? i can't use sqrt in func??
  31. let(hprim = curve*cos(lw))
  32. let(ueber = curve*sin(lw))
  33. for (x = [-b/2: 1 : 0])
  34. let(y0 = baseForm(x,b,l))
  35. let(beta = curveAngle(l, y0, ueber, lw,hprim))
  36. T_(0, y0, 0,
  37. Rx_(90,
  38. vec3D(
  39. transvCut2D(x,curve*cos(beta)-hprim,d)
  40. ))
  41. )
  42. ];
  43.  
  44.  
  45.  
  46.  
  47. module kieferDraw(b,l,lw=10, d=2)
  48. {
  49. curve = sqrt(l*l+ b*b/4);
  50. hprim = curve*cos(lw);
  51. ueber = curve*sin(lw);
  52.  
  53. sweep(trajectory(b,l,lw, d,curve)); //
  54. //for(x = [-b/2: 1 : 0])
  55. //{
  56. // y0 = baseForm(x,b,l);
  57. // beta = curveAngle(l, y0, ueber, lw,hprim);
  58. // data = transvCut2D(x,curve*cos(beta)-hprim,d);
  59. // echo("data ",data);
  60. // translate([0,y0,0]) rotate([90,0,0])polygon(data);
  61. //}
  62. }
  63.  
  64.  
  65. function roundPoint(pt,rad, res = 3,above = true, left = false) =
  66. [
  67. //(above == true)?
  68. for(n = [((left)? res:0):((left)? -1:1):((left)? 0:res)])
  69. let (w = ((above)?0:180) + 180/res*n)
  70. [pt[0]+rad*cos(w),pt[1], pt[2]+rad*sin(w)]
  71. // :
  72. // for(n = [0:1:res])
  73. // let (w = 180/res*n)
  74. // [pt[0]+rad*cos(w),pt[1], pt[2]+rad*sin(w)]
  75. ];
  76. function transvCut(x,y,z,d=1,res=3) =
  77. [
  78. each(roundPoint([-x,y,z],d,res)),
  79. each(roundPoint([0,y,z+x],d,res, above = 0)),
  80. each(roundPoint([x,y,z],d,res))
  81. ];
  82. function kieferPoly(b,l,lw=10, d=2) =
  83. let(curve = sqrt(l*l+ b*b/4))
  84. let(hprim = curve*cos(lw))
  85. let( ueber = curve*sin(lw))
  86. [
  87. for(x = [-b/2: 1 : 0])
  88. let(y0 = baseForm(x,b,l))
  89. let(beta = curveAngle(l, y0, ueber, lw,hprim))
  90. each(transvCut(x,y0,curve*cos(beta)-hprim,d)),
  91. ];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement