Reorganize around function/purpose rather than file type.

This commit is contained in:
2024-04-07 18:49:47 -05:00
parent 42e78ed35e
commit d4af5d3c36
141 changed files with 101779 additions and 0 deletions

52
lib/arc_cylinder.scad Normal file
View File

@ -0,0 +1,52 @@
module triangularPrism(angle, side1, side2, height) {
linear_extrude(height)
polygon(points = [[0, 0], [0, side1], [side2 * sin(angle), side2 * cos(angle)]]);
}
module arcCylinder(outerRadius, height, degrees, innerRadius = 0, center = false) {
epsilon = 0.01;
degToCut = 360 - (degrees % 360);
triDeg = degToCut % 60;
triSideLen = (outerRadius + epsilon) / cos(triDeg / 2);
fullTriSide = (outerRadius + epsilon) / cos(30);
numFullTriangles = floor(degToCut / 60);
difference() {
// Main cylinder body
cylinder(h=height, r=outerRadius);
// Exclusion
translate([0, 0, -1*epsilon]) union() {
// Inner cylinder (to form hole creating the wall)
if (innerRadius > 0) {
cylinder(h=height + 2*epsilon, r=max(0, innerRadius));
}
// Partial circle cut-out
if (degToCut < 360) {
rotate([0, 0, -90 - 60 * numFullTriangles]) union() {
// All 60-degree cuts get an eqilateral triangle.
if (degToCut >= 60) {
for (i = [1:numFullTriangles]) {
// rotate([-60 * i, 0, 0]) mirror([0, 1, 0]) cube([cubeSideLen, cubeSideLen, height + 2*epsilon]);
rotate([0, 0, 60 * i]) triangularPrism(
angle = 60.1,
side1 = fullTriSide,
side2 = fullTriSide,
height = height + 2*epsilon);
}
}
// Cut out the remaining angle with a triangular prism
rotate([0, 0, 0.1]) triangularPrism(
angle = triDeg + 0.1,
side1 = triSideLen,
side2 = triSideLen,
height = height + 2*epsilon);
}
}
}
}
}

11
lib/cable_sleeve.scad Normal file
View File

@ -0,0 +1,11 @@
include <arc_cylinder.scad>;
module cableSleeve(cableDiameter, length) {
innerRadius = (cableDiameter + 1) / 2; // give 1mm clearence for the cable
arcCylinder(
height = length,
outerRadius = innerRadius + 2,
innerRadius = innerRadius,
degrees = 360 - (2 * asin(cableDiameter / (cableDiameter + 2))));
}

24
lib/chamfered-cube.scad Normal file
View File

@ -0,0 +1,24 @@
module chamferedCube(size = [1, 1, 1], chamfer = 1) {
ep = 0.01;
difference() {
cube(size);
// X-axis
for (i = [0:3]) {
translate([-ep, size[1] * floor(i/2), size[2] * (i%2) - chamfer])
rotate([45, 0, 0]) cube([size[0] + 2*ep, 1.414*chamfer, 1.414*chamfer]);
}
// Y-axis
for (i = [0:3]) {
translate([size[0] * floor(i/2) - chamfer, -ep, size[2] * (i%2)])
rotate([0, 45, 0]) cube([1.414*chamfer, size[1] + 2*ep, 1.414*chamfer]);
}
// Z-axis
for (i = [0:3]) {
translate([size[0] * floor(i/2), size[1] * (i%2) - chamfer, -ep])
rotate([0, 0, 45]) cube([1.414*chamfer, 1.414*chamfer, size[2] + 2*ep]);
}
}
}

18
lib/skew.scad Normal file
View File

@ -0,0 +1,18 @@
/*skew takes an array of six angles:
*x along y
*x along z
*y along x
*y along z
*z along x
*z along y
*/
module skew(dims) {
matrix = [
[ 1, tan(dims[0]), tan(dims[1]), 0 ],
[ tan(dims[2]), 1, tan(dims[3]), 0 ],
[ tan(dims[4]), tan(dims[5]), 1, 0 ],
[ 0, 0, 0, 1 ]
];
multmatrix(matrix)
children();
}