Created
February 18, 2025 21:26
-
-
Save ebadi/bbe759f99f22f29cb46578fd7c95e93e to your computer and use it in GitHub Desktop.
OpenScad code for bathroom hook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module line(point1, point2, width = 1, cap_round = true) { | |
angle = 90 - atan((point2[1] - point1[1]) / (point2[0] - point1[0])); | |
offset_x = 0.5 * width * cos(angle); | |
offset_y = 0.5 * width * sin(angle); | |
offset1 = [-offset_x, offset_y]; | |
offset2 = [offset_x, -offset_y]; | |
if(cap_round) { | |
translate(point1) circle(d = width, $fn = 24); | |
translate(point2) circle(d = width, $fn = 24); | |
} | |
polygon(points=[ | |
point1 + offset1, point2 + offset1, | |
point2 + offset2, point1 + offset2 | |
]); | |
} | |
module polyline(points, width = 1) { | |
module polyline_inner(points, index) { | |
if(index < len(points)) { | |
line(points[index - 1], points[index], width); | |
polyline_inner(points, index + 1); | |
} | |
} | |
polyline_inner(points, 1); | |
} | |
linear_extrude(height = 1, center = true) | |
{ | |
polyline([[3.7, 0], [4,0], [4,4], [0,4] , [0,-1], [-3,-1], [-3, 0], [-2.5, 0.5]], 1); | |
polyline([ [-1.5,-1], [-1.5,0], [-1,0.3] ], 0.5); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment