1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-14 02:34:12 +02:00

refactor/format

This commit is contained in:
Justin Lin
2022-04-04 18:58:32 +08:00
parent 556fd1ed28
commit c3425143c3
12 changed files with 73 additions and 99 deletions

View File

@@ -17,7 +17,6 @@ module bauer_text_sphere(radius, font_name, font_size, txt_extrude, txt_scale, b
pts = bauer_spiral(n, radius);
if(ball) {
render()
sphere(radius * 0.9);
}
/*
@@ -25,10 +24,10 @@ module bauer_text_sphere(radius, font_name, font_size, txt_extrude, txt_scale, b
Bauer R. Distribution of points on a sphere with application to star catalogs. Journal of Guidance, Control, and Dynamics. 2000;23(1):130137
*/
for(i = [0:n - 1]) {
x = pts[i][0];
y = pts[i][1];
z = pts[i][2];
ya = atan2(z, sqrt(x * x + y * y));
x = pts[i].x;
y = pts[i].y;
z = pts[i].z;
ya = atan2(z, norm([x, y]));
za = atan2(y, x);
render()

View File

@@ -10,7 +10,7 @@ module heart(radius, center = false) {
module heart_sub_component() {
translate([-radius * cos(rotated_angle), 0, 0])
rotate(-rotated_angle) union() {
rotate(-rotated_angle) {
circle(radius);
translate([0, -radius, 0])
square(diameter);

View File

@@ -20,7 +20,7 @@ module nautilus_shell(chambered_section_max_angle, steps, thickness) {
];
half_thickness = thickness / 2;
render() {
polyline_join(spiral)
circle(half_thickness);
@@ -34,8 +34,6 @@ module nautilus_shell(chambered_section_max_angle, steps, thickness) {
polyline_join(bezier_curve(0.1, [p1, p2, p3]))
circle(half_thickness);
}
}
}
ellipse_extrude(semi_minor_axis, height = height, slices = slices)

View File

@@ -58,14 +58,8 @@ module seashell() {
);
points = [
for(s = [s_s:s_step:s_e])
for(theta = [theta_s:theta_step:theta_e])
let(
x = x(theta, s),
y = y(theta, s),
z = z(theta, s)
)
[x, y, z]
for(s = [s_s:s_step:s_e], theta = [theta_s:theta_step:theta_e])
[x(theta, s), y(theta, s), z(theta, s)]
];
slen = floor((s_e - s_s) / s_step);
@@ -73,15 +67,12 @@ module seashell() {
c = thetalen + 1;
triangles = [
for(s = [0:slen - 1])
for(theta = [0:thetalen - 1])
for(s = [0:slen - 1], theta = [0:thetalen - 1])
each [
[theta + s * c, theta + 1 + s * c, theta + (s + 1) * c],
[theta + 1 + s * c, theta + 1 + (s + 1) * c, theta + (s + 1) * c]
]
];
sf_thickenT(points, thickness, triangles);
}

View File

@@ -39,8 +39,7 @@ module spiral_city(num_of_buildings, seed_value) {
ra_arc = atan2(mid_pt[1], mid_pt[0]) - (i > leng_pts - 4 ? arc_a / 4.5 : arc_a / 5);
translate(mid_pt)
rotate(ra_arc)
union() {
rotate(ra_arc) {
difference() {
union() {
linear_extrude(building_h)
@@ -55,7 +54,6 @@ module spiral_city(num_of_buildings, seed_value) {
cubes(i, arm_distance, building_h, w_size, arc_a, arc_r, seed_value);
}
roof(i, arm_distance, building_h, roof_h, arc_a, arc_r);
}
}
@@ -66,7 +64,7 @@ module spiral_city(num_of_buildings, seed_value) {
half_a = arc_a / 2;
is_even = i % 2 == 0;
arc_w = arm_distance / (is_even ? 2.5 : 1.7);
union() {
rs = is_undef(seed_value) ?
rands(-1, 1, 4) :
rands(-1, 1, 4, seed_value = seed_value + i);
@@ -102,7 +100,6 @@ module spiral_city(num_of_buildings, seed_value) {
}
}
}
}
module roof(i, arm_distance, building_h, roof_h, arc_a, arc_r) {
is_even = i % 2 == 0;

View File

@@ -30,9 +30,9 @@ module spiral_math_constants(n, radius, constants, font_name, font_size, txt_ext
module constant_on_spiral(constant, spiral) {
for(i = [0:len(spiral) - 1]) {
x = spiral[i][0];
y = spiral[i][1];
z = spiral[i][2];
x = spiral[i].x;
y = spiral[i].y;
z = spiral[i].z;
ya = atan2(z, sqrt(x * x + y * y));
za = atan2(y, x);

View File

@@ -48,8 +48,7 @@ module dog_back(head_r, peg_radius) {
$fn = 36;
module foot() {
translate([head_r, 0, 0])
union() {
translate([head_r, 0, 0]) {
color("PapayaWhip")
ellipse_extrude(head_r / 3)
polygon(shape_ellipse([head_r / 3, head_r / 2]));

View File

@@ -10,12 +10,8 @@ model = "Tetrahedron"; // [Tetrahedron, Base, Both]
module string_tetrahedron(leng, diameter, segs_per_side, line_fn) {
module lines_between(side1, side2, diameter, segs) {
function pts(p1, p2, segs) =
let(
p = p2 - p1,
dx = p[0] / segs,
dy = p[1] / segs,
dz = p[2] / segs
) [for(i = [0:segs]) p1 + [dx, dy, dz] * i];
let(p = p2 - p1)
[for(i = [0:segs]) p1 + p / segs * i];
pts1 = pts(side1[0], side1[1], segs);
pts2 = pts(side2[0], side2[1], segs);

View File

@@ -9,12 +9,7 @@ center = false;
module string_tetrahedron(leng, diameter, segs_per_side, line_fn) {
module lines_between(side1, side2, diameter, segs) {
function pts(p1, p2, segs) =
let(
p = p2 - p1,
dx = p[0] / segs,
dy = p[1] / segs,
dz = p[2] / segs
) [for(i = [0:segs]) p1 + [dx, dy, dz] * i];
let(p = p2 - p1) [for(i = [0:segs]) p1 + p / segs * i];
pts1 = pts(side1[0], side1[1], segs);
pts2 = pts(side2[0], side2[1], segs);
@@ -95,7 +90,6 @@ module string_tetrahedrons(level, leng, diameter, segs_per_side, center) {
for(i = [0:120:240]) {
rotate(i)
translate([0, -center_y * 2])
rotate([a, 0, 0])
translate([0, center_y * 2])

View File

@@ -9,7 +9,7 @@ linear_extrude(2)
translate(pts[i])
difference() {
square(7, center = true);
render() for(p = vx_ascii(tx[i], center = true)) {
for(p = vx_ascii(tx[i], center = true)) {
translate(p) square(.8);
}
}