Advertisement
j0h

shapes_scad

j0h
Jun 28th, 2025
529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.56 KB | None | 0 0
  1. // Triangular Prism Module
  2. module triangular_prism(base=20, height=15, depth=30) {
  3.     polyhedron(
  4.         points=[
  5.             [0, 0, 0],           // 0: base left
  6.             [base, 0, 0],        // 1: base right
  7.             [base/2, height, 0], // 2: top
  8.             [0, 0, depth],       // 3: back base left
  9.             [base, 0, depth],    // 4: back base right
  10.             [base/2, height, depth] // 5: back top
  11.         ],
  12.         faces=[
  13.             [0, 1, 2], // front triangle
  14.             [3, 5, 4], // back triangle
  15.             [0, 2, 5, 3], // left side
  16.             [1, 4, 5, 2], // right side
  17.             [0, 3, 4, 1]  // bottom rectangle
  18.         ]
  19.     );
  20. }
  21.  
  22.  
  23.  
  24. // Equilateral Triangular Prism
  25. module equilateral_prism(side=20, depth=30) {
  26.     h = side * sqrt(3) / 2; // height of equilateral triangle
  27.  
  28.     polyhedron(
  29.         points=[
  30.             [0, 0, 0],          // 0: base left
  31.             [side, 0, 0],       // 1: base right
  32.             [side/2, h, 0],     // 2: top center
  33.             [0, 0, depth],      // 3: back base left
  34.             [side, 0, depth],   // 4: back base right
  35.             [side/2, h, depth]  // 5: back top center
  36.         ],
  37.         faces=[
  38.             [0, 1, 2],        // front triangle
  39.             [3, 5, 4],        // back triangle
  40.             [0, 2, 5, 3],     // left side
  41.             [1, 4, 5, 2],     // right side
  42.             [0, 3, 4, 1]      // bottom rectangle
  43.         ]
  44.     );
  45. }
  46.  
  47. module box(){
  48. cube([5,5,2]);
  49. }
  50.  
  51. module cyl(){
  52. cylinder([5,5,5]);
  53. }
  54.  
  55.  
  56. //triangular_prism();
  57. equilateral_prism();
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement