reorganize old files, and update readme with banner image

This commit is contained in:
zhao
2023-01-08 19:00:04 -05:00
parent 407090507d
commit 43c2aceba5
12 changed files with 6 additions and 11293 deletions

12
helper/common.scad Normal file
View File

@ -0,0 +1,12 @@
/* Some commonly used variables plus functions
*/
$fn=64;
eps=0.0001;
inf10 = 10;
inf50 = 50;
inf1000 = 1000;
inf = inf1000;

12
helper/math.scad Normal file
View File

@ -0,0 +1,12 @@
/* Example usage:
for (i=mirror4XY(midpoint=[0,0,0], offsetX=90, offsetY=90)) {
translate(v=i)
something();
}
*/
function mirror4XY(midpoint, offsetX, offsetY) =
[[midpoint[0]+offsetX, midpoint[1]+offsetY, midpoint[2]],
[midpoint[0]-offsetX, midpoint[1]+offsetY, midpoint[2]],
[midpoint[0]-offsetX, midpoint[1]-offsetY, midpoint[2]],
[midpoint[0]+offsetX, midpoint[1]-offsetY, midpoint[2]]];

62
helper/sinusoid.scad Normal file
View File

@ -0,0 +1,62 @@
length = 100;
resolution = 128;
amplitude = 4.0;
period = PI;
shift = 0.0;
function radToDeg(r) = r * (180 / PI);
function sinR(r) = sin(radToDeg(r));
//sigmoid = function(x) exp(x) / (exp(x) + 1);
//dsigmoid = function(x) sigmoid(x) * (1-sigmoid(x));
//amplitudeFunction = function(x) 5*dsigmoid(x - 3) + 1;
amplitudeFunction = function(x) 1;
module sineWave(length, resolution, amplitudeFunction, period, shift) {
dx = length / resolution;
p = period / (2*PI);
for (i = [1:resolution]) {
idx_prev = (i - 1) * dx;
idx_curr = i * dx;
hull() {
translate(v = [idx_prev, amplitudeFunction(idx_prev) * sinR(p * idx_prev + shift), 0])
cube(size = [0.1, 2, 2]);
translate(v = [idx_curr, amplitudeFunction(idx_curr) * sinR(p * idx_curr + shift), 0])
cube(size = [0.1, 2, 2]);
translate(v = [idx_curr, -10, 0])
cube(size=[0.1,2,2]);
translate(v = [idx_prev, -10, 0])
cube(size=[0.1,2,2]);
}
}
}
module sineWaveHull(length, resolution, amplitudeFunction, period, shift, hullDiff) {
dx = length / resolution;
p = period / (2*PI);
for (i = [1:resolution]) {
idx_prev = (i - 1) * dx;
idx_curr = i * dx;
hull() {
translate(v = [idx_prev, amplitudeFunction(idx_prev) * sinR(p * idx_prev + shift), 0])
cube(size = [0.1, 2, 2]);
translate(v = [idx_curr, amplitudeFunction(idx_curr) * sinR(p * idx_curr + shift), 0])
cube(size = [0.1, 2, 2]);
translate(v = [idx_curr, -hullDiff, 0])
cube(size=[0.1,2,2]);
translate(v = [idx_prev, -hullDiff, 0])
cube(size=[0.1,2,2]);
}
}
}
//sineWaveHull(length, resolution, amplitudeFunction, period, shift, 10);