1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-13 18:24:28 +02:00
This commit is contained in:
Justin Lin
2021-07-22 13:31:16 +08:00
parent 5d593ecbc3
commit 9c487ec304
9 changed files with 328 additions and 761 deletions

View File

@@ -1,105 +1,11 @@
use <ellipse_extrude.scad>; use <ellipse_extrude.scad>;
use <torus_knot.scad>;
use <shear.scad>;
use <curve.scad>; use <curve.scad>;
use <along_with.scad>;
use <sweep.scad>; use <sweep.scad>;
use <paths2sections.scad>; use <paths2sections.scad>;
use <shape_trapezium.scad>; use <shape_trapezium.scad>;
use <util/reverse.scad>;
use <ptf/ptf_rotate.scad>; use <ptf/ptf_rotate.scad>;
torus_knot_dragon2(); module dragon_head(angy_angz) {
module torus_knot_dragon2() {
phi_step = 0.05;
knot = torus_knot(2, 3, phi_step);
d_path = reverse([for(i = [6:len(knot) - 4]) knot[i]]);
along_with(d_path, scale = 0.85, method = "EULER_ANGLE")
scale(0.06)
one_segment();
function __angy_angz(p1, p2) =
let(
dx = p2[0] - p1[0],
dy = p2[1] - p1[1],
dz = p2[2] - p1[2],
ya = atan2(dz, sqrt(dx * dx + dy * dy)),
za = atan2(dy, dx)
) [ya, za];
h_angy_angz = __angy_angz(d_path[len(d_path) - 2], d_path[len(d_path) - 1]);
translate([2.75, -.9, .45])
rotate([0, 28, 245])
scale(0.0625)
head(h_angy_angz);
t_angy_angz = __angy_angz(d_path[1], d_path[0]);
translate([2.25, 1.5, -.8])
rotate([0, t_angy_angz[0], t_angy_angz[1]])
rotate([0, -100, -90])
scale([0.0525, 0.0525, 0.06])
tail();
}
module scales(ang, leng, radius, height, thickness) {
module one_scale() {
rotate([0, ang, 0])
shear(sx = [0, -1.5])
linear_extrude(thickness, center = true)
scale([leng, 1])
circle(1, $fn = 4);
}
for(a = [0:30:330]) {
hull() {
rotate(a)
translate([radius, 0, height])
one_scale();
rotate(a + 15)
translate([radius, 0, height + 1.75])
one_scale();
}
}
}
module one_segment() {
// scales
scale([1,0.85,1]) union() {
scales(60, 4, 5, 0, 1.5);
scales(75, 2.5, 5, -4, 1.25);
scales(100, 1.25, 4.5, -7, 1);
// %scales(110, 1.25, 3, -9, 1);
// %scales(120, 2.5, 2, -9, 1);
}
// dorsal fin
translate([0, 2.5, -3])
rotate([-65, 0, 0])
shear(sy = [0, 2])
linear_extrude(4, scale = 0.2)
square([2, 10], center = true);
// belly
hull() {
translate([0, -2.5, 1])
rotate([-10, 0, 0])
scale([1.1, 0.8, 1.25])
sphere(5.8, $fn = 8);
translate([0, 0, -1.65])
rotate([-5, 0, 0])
scale([1, 0.8, 1.6])
sphere(5.5, $fn = 8);
}
}
module head(angy_angz) {
module hair() { module hair() {
for(i = [16:36]) { for(i = [16:36]) {
rotate(i * 10) rotate(i * 10)
@@ -207,14 +113,4 @@ module head(angy_angz) {
mirror([0, 1, 0]) one_beard(); mirror([0, 1, 0]) one_beard();
} }
} }
}
module tail() {
scale([1,0.85,1]) union() {
// scales(60, 4, 5, 0, 1.5);
scales(75, 2.5, 5, -4, 1.25);
scales(100, 1.25, 4.5, -7, 1);
scales(110, 1.25, 3, -9, 1);
scales(120, 2.5, 2, -9, 1);
}
} }

View File

@@ -1,50 +1,8 @@
use <bezier_curve.scad>; use <bezier_curve.scad>;
use <ellipse_extrude.scad>;
use <path_extrude.scad>; use <path_extrude.scad>;
use <shape_circle.scad>; use <shape_circle.scad>;
use <torus_knot.scad>;
use <util/reverse.scad>;
torus_knot_dragon(); module dragon_head_low_poly() {
module torus_knot_dragon() {
phi_step = 0.04;
knot = torus_knot(2, 3, phi_step);
dragon_body_path = reverse([for(i = [9:len(knot) - 3]) knot[i]]);
body_shape = concat(
bezier_curve(0.25,
[
[30, -35], [16, 0], [4, 13],
[3, -5], [0, 26], [-3, -5],
[-4, 13], [-16, 0], [-30, -35]
]
),
bezier_curve(0.25,
[[-22, -35], [-15, -45], [0, -55], [15, -45], [22, -35]]
)
);
pts = [for(p = body_shape) p * 0.015];
p = dragon_body_path[0];
path_extrude(pts, concat([p + [0.00001, 0.0000055, 0.000008]], dragon_body_path), scale = 0.9);
translate([2.975, -0.75, -0.75])
scale(0.01825)
rotate([-52, -9, -25])
dragon_head();
translate([1.84, 1.635, -0.885])
rotate([104.95, -154.35, 66.25])
ellipse_extrude(1.2, slices = 7, twist = 15)
scale(0.9 * 0.0150)
polygon(body_shape);
}
module dragon_head() {
module palate() { module palate() {
t_step = 0.15; t_step = 0.15;

View File

@@ -0,0 +1,104 @@
use <shear.scad>;
use <along_with.scad>;
use <bezier_smooth.scad>;
use <util/reverse.scad>;
use <util/dedup.scad>;
use <turtle/lsystem3.scad>;
use <curve.scad>;
use <dragon_head.scad>;
hilbert_dragon();
module hilbert_dragon() {
module scales(ang, leng, radius, height, thickness) {
module one_scale() {
rotate([0, ang, 0])
shear(sx = [0, -1.5])
linear_extrude(thickness, center = true)
scale([leng, 1.6])
circle(1, $fn = 4);
}
for(a = [0:45:315]) {
hull() {
rotate(a)
translate([radius, 0, height])
one_scale();
rotate(a + 15)
translate([radius, 0, height + 1.75])
one_scale();
}
}
}
module one_segment() {
// scales
scale([1, 0.8, 1]) union() {
scales(60, 4, 5, 0, 1.5);
scales(75, 2.5, 5, -4, 1.25);
scales(100, 1.25, 4.5, -7, 1);
scales(110, 1.25, 3, -9, 1);
// scales(120, 2.5, 2, -9, 1);
}
// dorsal fin
translate([0, 4, -1.5])
rotate([-105, 0, 0])
shear(sy = [0, .75])
linear_extrude(5, scale = 0.15)
square([2.5, 4], center = true);
hull() {
// belly
translate([0, -2.5, 1])
rotate([-10, 0, 0])
scale([1.1, 0.8, 1.25])
sphere(5.8, $fn = 8);
translate([0, 0, -1.65])
rotate([-5, 0, 0])
scale([1, 0.8, 1.6])
sphere(5.5, $fn = 8);
}
}
lines = hilbert_curve();
hilbert_path = dedup(
concat(
[for(line = lines) line[0]],
[lines[len(lines) - 1][1]])
);
smoothed_hilbert_path = bezier_smooth(hilbert_path, 0.45, t_step = 0.2);
dragon_body_path = reverse([for(i = [1:len(smoothed_hilbert_path) - 2]) smoothed_hilbert_path[i]]);
along_with(dragon_body_path, scale = 0.6)
rotate([90, 0, 0])
scale(0.035)
one_segment();
// tail
translate([0, 0, -0.62])
rotate(-5)
scale(0.0285)
mirror([0, 0, 1])
scales(120, 2.5, 2, -9, 1);
translate([0, 0, -2.5])
scale(0.035)
dragon_head([0, 0]);
}
function hilbert_curve() =
let(
axiom = "A",
rules = [
["A", "B-F+CFC+F-D&F^D-F+&&CFC+F+B//"],
["B", "A&F^CFB^F^D^^-F-D^|F^B|FC^F^A//"],
["C", "|D^|F^B-F+C^F^A&&FA&F^C+F+B^F^D//"],
["D", "|CFB-F+B|FA&F^A&&FB-F+B|FC//"]
]
)
lsystem3(axiom, rules, 2, 90, 1, 0, [0, 0, 0]);

View File

@@ -0,0 +1,67 @@
use <bezier_smooth.scad>;
use <bezier_curve.scad>;
use <ellipse_extrude.scad>;
use <path_extrude.scad>;
use <util/reverse.scad>;
use <util/dedup.scad>;
use <turtle/lsystem3.scad>;
use <dragon_head_low_poly.scad>;
hilbert_dragon_low_poly();
module hilbert_dragon_low_poly() {
lines = hilbert_curve();
hilbert_path = dedup(
concat(
[for(line = lines) line[0]],
[lines[len(lines) - 1][1]])
);
smoothed_hilbert_path = bezier_smooth(hilbert_path, 0.48, t_step = 0.2);
dragon_body_path = reverse([for(i = [1:len(smoothed_hilbert_path) - 2]) smoothed_hilbert_path[i]]);
body_shape = concat(
bezier_curve(0.25,
[
[30, -35], [16, 0], [4, 13],
[3, -5], [0, 26], [-3, -5],
[-4, 13], [-16, 0], [-30, -35]
]
),
bezier_curve(0.25,
[[-22, -35], [-15, -45], [0, -55], [15, -45], [22, -35]]
)
);
pts = [for(p = body_shape) p * 0.007];
p = dragon_body_path[0];
path_extrude(pts, concat([p + [0.0155, 0, 0.175]], [for(i = [1:len(dragon_body_path) - 1]) dragon_body_path[i]]), scale = 0.9);
translate([0.125, 0, -2.73])
scale(0.009)
rotate([-60, 0, 90])
dragon_head_low_poly();
translate([0, 0, -0.525])
rotate([0, -7, 0])
rotate(90)
ellipse_extrude(0.5, slices = 4, twist = 15)
scale(0.9 * 0.007)
polygon(body_shape);
}
function hilbert_curve() =
let(
axiom = "A",
rules = [
["A", "B-F+CFC+F-D&F^D-F+&&CFC+F+B//"],
["B", "A&F^CFB^F^D^^-F-D^|F^B|FC^F^A//"],
["C", "|D^|F^B-F+C^F^A&&FA&F^C+F+B^F^D//"],
["D", "|CFB-F+B|FA&F^A&&FB-F+B|FC//"]
]
)
lsystem3(axiom, rules, 2, 90, 1, 0, [0, 0, 0]);

View File

@@ -1,17 +1,13 @@
use <helix.scad>; use <helix.scad>;
use <along_with.scad>; use <along_with.scad>;
use <shape_trapezium.scad>;
use <ellipse_extrude.scad>;
use <shear.scad>; use <shear.scad>;
use <curve.scad>; use <curve.scad>;
use <sweep.scad>; use <sweep.scad>;
use <paths2sections.scad>;
use <ptf/ptf_rotate.scad>;
use <shape_circle.scad>; use <shape_circle.scad>;
use <bezier_curve.scad>; use <bezier_curve.scad>;
use <path_scaling_sections.scad>; use <path_scaling_sections.scad>;
use <util/rand.scad>;
use <noise/nz_perlin2s.scad>; use <noise/nz_perlin2s.scad>;
use <dragon_head.scad>;
r1 = 25; r1 = 25;
r2 = 15; r2 = 15;
@@ -81,117 +77,7 @@ module tail() {
} }
} }
module head(angy_angz) { module spiral_dragon() {
module hair() {
for(i = [16:36]) {
rotate(i * 10)
translate([0, -13, 0])
rotate([9, 0, 0])
linear_extrude(15, scale = 0.05, twist = 50 - rands(0, 100, 1, seed = i)[0])
translate([0, 10, 0])
circle(3, $fn = 4);
}
for(i = [0:35]) {
rotate(i * 12)
translate([0, -11.5, 0])
rotate([5, 0, 0])
linear_extrude(20, scale = 0.05, twist = 50 - rands(0, 100, 1, seed = i + 1)[0])
translate([0, 10, 0])
circle(3.2, $fn = 5);
}
for(i = [0:35]) {
rotate(i * 10)
translate([0, -10, 0])
rotate([2, 0, 0])
linear_extrude(22, scale = 0.05, twist = 50 - rands(0, 100, 1, seed = i + 2)[0])
translate([0, 10, 0])
circle(3, $fn = 5);
}
}
module one_horn() {
translate([-9, -4, -2])
rotate([45, -25, 0])
linear_extrude(30, scale = 0.1, twist = -90)
translate([7.5, 0, 0])
circle(3, $fn = 4);
}
module mouth() {
path1 = curve(0.4, [[0, -8, -1], [0, -11, .25], [0, -12, 5], [0, -9, 5], [0, -4, 6], [0, -0.5, 8], [0, 5, 6.5], [0, 8, 6], [0, 12, 1], [0, 16, 0]]);
path2 = [for(p = path1) ptf_rotate(p, [0, -12, 0]) * 0.9 + [-2, 0, 0]];
path3 = [for(i = [0:len(path1) - 1]) [-i / 6 - 1.5, i / 1.65 - 9, 0]];
path4 = [for(p = path3) [-p[0], p[1], p[2]]];
path5 = [for(p = path2) [-p[0], p[1], p[2]]];
translate([0, 0, -2])
rotate([90, 0, -90])
sweep(paths2sections([path1, path2, path3, path4, path5]));
translate([0, 0, -3.25])
rotate([90, 0, -90])
ellipse_extrude(5.5, slices = 2)
polygon(
shape_trapezium([5, 18],
h = 20,
corner_r = 2, $fn = 4)
);
mirror([1, 0, 0])
translate([0, 0, -3])
rotate([85, 0, -90])
ellipse_extrude(4, slices = 2)
polygon(
shape_trapezium([5, 18],
h = 20,
corner_r = 2, $fn = 5)
);
}
module one_eye() {
translate([-5, 2.5, -2])
rotate([-5, -8, -10])
scale([1, 1, 1.75])
sphere(1.75, $fn = 6);
translate([-5.1, 3.75, -2.25])
rotate([-25, 0, 75])
sphere(0.65, $fn = 6);
}
module one_beard() {
translate([-11.15, -12, -10])
rotate(180)
linear_extrude(8, scale = 0.2, twist = 90)
translate([-10, -10, 0])
circle(1, $fn = 6);
}
rotate([0, angy_angz[0] + 15, angy_angz[1]])
translate([0, 0, -25 / 2])
scale(1.15) {
scale([0.8, 0.9, 1]) hair();
translate([0, 0, 2]) {
rotate(-90) {
one_horn();
mirror([-1, 0, 0]) one_horn();
}
mouth();
one_eye();
mirror([0, 1, 0]) one_eye();
one_beard();
mirror([0, 1, 0]) one_beard();
}
}
}
module dragon() {
path_pts = helix( path_pts = helix(
radius = [r1, r2], radius = [r1, r2],
levels = levels, levels = levels,
@@ -224,7 +110,7 @@ module dragon() {
translate([19, 0, 65]) translate([19, 0, 65])
rotate([95, 0, 0]) rotate([95, 0, 0])
head(angy_angz); dragon_head(angy_angz);
} }
module flame_mountain(beginning_radius, fn, amplitude,curve_step, smoothness) { module flame_mountain(beginning_radius, fn, amplitude,curve_step, smoothness) {
@@ -266,7 +152,7 @@ module flame_mountain(beginning_radius, fn, amplitude,curve_step, smoothness) {
rotate(180) { rotate(180) {
translate([0, 0, 7]) translate([0, 0, 7])
dragon($fn = 12); spiral_dragon($fn = 12);
rotate(60) rotate(60)
flame_mountain( flame_mountain(
beginning_radius = 26, beginning_radius = 26,

View File

@@ -0,0 +1,105 @@
use <torus_knot.scad>;
use <shear.scad>;
use <along_with.scad>;
use <util/reverse.scad>;
use <dragon_head.scad>;
torus_knot_dragon();
module torus_knot_dragon() {
phi_step = 0.05;
knot = torus_knot(2, 3, phi_step);
d_path = reverse([for(i = [6:len(knot) - 4]) knot[i]]);
along_with(d_path, scale = 0.85, method = "EULER_ANGLE")
scale(0.06)
one_segment();
function __angy_angz(p1, p2) =
let(
dx = p2[0] - p1[0],
dy = p2[1] - p1[1],
dz = p2[2] - p1[2],
ya = atan2(dz, sqrt(dx * dx + dy * dy)),
za = atan2(dy, dx)
) [ya, za];
h_angy_angz = __angy_angz(d_path[len(d_path) - 2], d_path[len(d_path) - 1]);
translate([2.75, -.9, .45])
rotate([0, 28, 245])
scale(0.0625)
dragon_head(h_angy_angz);
t_angy_angz = __angy_angz(d_path[1], d_path[0]);
translate([2.25, 1.5, -.8])
rotate([0, t_angy_angz[0], t_angy_angz[1]])
rotate([0, -100, -90])
scale([0.0525, 0.0525, 0.06])
tail();
}
module scales(ang, leng, radius, height, thickness) {
module one_scale() {
rotate([0, ang, 0])
shear(sx = [0, -1.5])
linear_extrude(thickness, center = true)
scale([leng, 1])
circle(1, $fn = 4);
}
for(a = [0:30:330]) {
hull() {
rotate(a)
translate([radius, 0, height])
one_scale();
rotate(a + 15)
translate([radius, 0, height + 1.75])
one_scale();
}
}
}
module one_segment() {
// scales
scale([1,0.85,1]) union() {
scales(60, 4, 5, 0, 1.5);
scales(75, 2.5, 5, -4, 1.25);
scales(100, 1.25, 4.5, -7, 1);
// %scales(110, 1.25, 3, -9, 1);
// %scales(120, 2.5, 2, -9, 1);
}
// dorsal fin
translate([0, 2.5, -3])
rotate([-65, 0, 0])
shear(sy = [0, 2])
linear_extrude(4, scale = 0.2)
square([2, 10], center = true);
// belly
hull() {
translate([0, -2.5, 1])
rotate([-10, 0, 0])
scale([1.1, 0.8, 1.25])
sphere(5.8, $fn = 8);
translate([0, 0, -1.65])
rotate([-5, 0, 0])
scale([1, 0.8, 1.6])
sphere(5.5, $fn = 8);
}
}
module tail() {
scale([1,0.85,1]) union() {
// scales(60, 4, 5, 0, 1.5);
scales(75, 2.5, 5, -4, 1.25);
scales(100, 1.25, 4.5, -7, 1);
scales(110, 1.25, 3, -9, 1);
scales(120, 2.5, 2, -9, 1);
}
}

View File

@@ -0,0 +1,46 @@
use <bezier_curve.scad>;
use <ellipse_extrude.scad>;
use <path_extrude.scad>;
use <torus_knot.scad>;
use <util/reverse.scad>;
use <dragon_head_low_poly.scad>;
torus_knot_dragon_low_poly();
module torus_knot_dragon_low_poly() {
phi_step = 0.04;
knot = torus_knot(2, 3, phi_step);
dragon_body_path = reverse([for(i = [9:len(knot) - 3]) knot[i]]);
body_shape = concat(
bezier_curve(0.25,
[
[30, -35], [16, 0], [4, 13],
[3, -5], [0, 26], [-3, -5],
[-4, 13], [-16, 0], [-30, -35]
]
),
bezier_curve(0.25,
[[-22, -35], [-15, -45], [0, -55], [15, -45], [22, -35]]
)
);
pts = [for(p = body_shape) p * 0.015];
p = dragon_body_path[0];
path_extrude(pts, concat([p + [0.00001, 0.0000055, 0.000008]], dragon_body_path), scale = 0.9);
translate([2.975, -0.75, -0.75])
scale(0.01825)
rotate([-52, -9, -25])
dragon_head_low_poly();
translate([1.84, 1.635, -0.885])
rotate([104.95, -154.35, 66.25])
ellipse_extrude(1.2, slices = 7, twist = 15)
scale(0.9 * 0.0150)
polygon(body_shape);
}

View File

@@ -1,219 +0,0 @@
use <shear.scad>;
use <along_with.scad>;
use <bezier_smooth.scad>;
use <ellipse_extrude.scad>;
use <shape_trapezium.scad>;
use <util/reverse.scad>;
use <util/dedup.scad>;
use <turtle/lsystem3.scad>;
use <curve.scad>;
use <sweep.scad>;
use <paths2sections.scad>;
use <ptf/ptf_rotate.scad>;
hilbert_dragon();
module hilbert_dragon() {
module scales(ang, leng, radius, height, thickness) {
module one_scale() {
rotate([0, ang, 0])
shear(sx = [0, -1.5])
linear_extrude(thickness, center = true)
scale([leng, 1.6])
circle(1, $fn = 4);
}
for(a = [0:45:315]) {
hull() {
rotate(a)
translate([radius, 0, height])
one_scale();
rotate(a + 15)
translate([radius, 0, height + 1.75])
one_scale();
}
}
}
module one_segment() {
// scales
scale([1, 0.8, 1]) union() {
scales(60, 4, 5, 0, 1.5);
scales(75, 2.5, 5, -4, 1.25);
scales(100, 1.25, 4.5, -7, 1);
scales(110, 1.25, 3, -9, 1);
// scales(120, 2.5, 2, -9, 1);
}
// dorsal fin
translate([0, 4, -1.5])
rotate([-105, 0, 0])
shear(sy = [0, .75])
linear_extrude(5, scale = 0.15)
square([2.5, 4], center = true);
hull() {
// belly
translate([0, -2.5, 1])
rotate([-10, 0, 0])
scale([1.1, 0.8, 1.25])
sphere(5.8, $fn = 8);
translate([0, 0, -1.65])
rotate([-5, 0, 0])
scale([1, 0.8, 1.6])
sphere(5.5, $fn = 8);
}
}
module head(angy_angz) {
module hair() {
for(i = [16:36]) {
rotate(i * 10)
translate([0, -13, 0])
rotate([9, 0, 0])
linear_extrude(15, scale = 0.05, twist = 50 - rands(0, 100, 1, seed = i)[0])
translate([0, 10, 0])
circle(3, $fn = 4);
}
for(i = [0:35]) {
rotate(i * 12)
translate([0, -11.5, 0])
rotate([5, 0, 0])
linear_extrude(20, scale = 0.05, twist = 50 - rands(0, 100, 1, seed = i + 1)[0])
translate([0, 10, 0])
circle(3.2, $fn = 5);
}
for(i = [0:35]) {
rotate(i * 10)
translate([0, -10, 0])
rotate([2, 0, 0])
linear_extrude(22, scale = 0.05, twist = 50 - rands(0, 100, 1, seed = i + 2)[0])
translate([0, 10, 0])
circle(3, $fn = 5);
}
}
module one_horn() {
translate([-9, -4, -2])
rotate([45, -25, 0])
linear_extrude(30, scale = 0.1, twist = -90)
translate([7.5, 0, 0])
circle(3, $fn = 4);
}
module mouth() {
path1 = curve(0.4, [[0, -8, -1], [0, -11, .25], [0, -12, 5], [0, -9, 5], [0, -4, 6], [0, -0.5, 8], [0, 5, 6.5], [0, 8, 6], [0, 12, 1], [0, 16, 0]]);
path2 = [for(p = path1) ptf_rotate(p, [0, -12, 0]) * 0.9 + [-2, 0, 0]];
path3 = [for(i = [0:len(path1) - 1]) [-i / 6 - 1.5, i / 1.65 - 9, 0]];
path4 = [for(p = path3) [-p[0], p[1], p[2]]];
path5 = [for(p = path2) [-p[0], p[1], p[2]]];
translate([0, 0, -2])
rotate([90, 0, -90])
sweep(paths2sections([path1, path2, path3, path4, path5]));
translate([0, 0, -3.25])
rotate([90, 0, -90])
ellipse_extrude(5.5, slices = 2)
polygon(
shape_trapezium([5, 18],
h = 20,
corner_r = 2, $fn = 4)
);
mirror([1, 0, 0])
translate([0, 0, -3])
rotate([85, 0, -90])
ellipse_extrude(4, slices = 2)
polygon(
shape_trapezium([5, 18],
h = 20,
corner_r = 2, $fn = 5)
);
}
module one_eye() {
translate([-5, 2.5, -2])
rotate([-5, -8, -10])
scale([1, 1, 1.75])
sphere(1.75, $fn = 6);
translate([-5.1, 3.75, -2.25])
rotate([-25, 0, 75])
sphere(0.65, $fn = 6);
}
module one_beard() {
translate([-11.15, -12, -10])
rotate(180)
linear_extrude(8, scale = 0.2, twist = 90)
translate([-10, -10, 0])
circle(1, $fn = 6);
}
rotate([0, angy_angz[0] + 15, angy_angz[1]])
translate([0, 0, -25 / 2])
scale(1.15) {
scale([0.8, 0.9, 1]) hair();
translate([0, 0, 2]) {
rotate(-90) {
one_horn();
mirror([-1, 0, 0]) one_horn();
}
mouth();
one_eye();
mirror([0, 1, 0]) one_eye();
one_beard();
mirror([0, 1, 0]) one_beard();
}
}
}
lines = hilbert_curve();
hilbert_path = dedup(
concat(
[for(line = lines) line[0]],
[lines[len(lines) - 1][1]])
);
smoothed_hilbert_path = bezier_smooth(hilbert_path, 0.45, t_step = 0.2);
dragon_body_path = reverse([for(i = [1:len(smoothed_hilbert_path) - 2]) smoothed_hilbert_path[i]]);
along_with(dragon_body_path, scale = 0.6)
rotate([90, 0, 0])
scale(0.035)
one_segment();
// tail
translate([0, 0, -0.62])
rotate(-5)
scale(0.0285)
mirror([0, 0, 1])
scales(120, 2.5, 2, -9, 1);
translate([0, 0, -2.5])
scale(0.035)
head([0, 0]);
}
function hilbert_curve() =
let(
axiom = "A",
rules = [
["A", "B-F+CFC+F-D&F^D-F+&&CFC+F+B//"],
["B", "A&F^CFB^F^D^^-F-D^|F^B|FC^F^A//"],
["C", "|D^|F^B-F+C^F^A&&FA&F^C+F+B^F^D//"],
["D", "|CFB-F+B|FA&F^A&&FB-F+B|FC//"]
]
)
lsystem3(axiom, rules, 2, 90, 1, 0, [0, 0, 0]);

View File

@@ -1,276 +0,0 @@
use <bezier_smooth.scad>;
use <bezier_curve.scad>;
use <ellipse_extrude.scad>;
use <path_extrude.scad>;
use <shape_circle.scad>;
use <util/reverse.scad>;
use <util/dedup.scad>;
use <turtle/lsystem3.scad>;
hilbert_dragon_low_poly();
module hilbert_dragon_low_poly() {
lines = hilbert_curve();
hilbert_path = dedup(
concat(
[for(line = lines) line[0]],
[lines[len(lines) - 1][1]])
);
smoothed_hilbert_path = bezier_smooth(hilbert_path, 0.48, t_step = 0.2);
dragon_body_path = reverse([for(i = [1:len(smoothed_hilbert_path) - 2]) smoothed_hilbert_path[i]]);
body_shape = concat(
bezier_curve(0.25,
[
[30, -35], [16, 0], [4, 13],
[3, -5], [0, 26], [-3, -5],
[-4, 13], [-16, 0], [-30, -35]
]
),
bezier_curve(0.25,
[[-22, -35], [-15, -45], [0, -55], [15, -45], [22, -35]]
)
);
pts = [for(p = body_shape) p * 0.007];
p = dragon_body_path[0];
path_extrude(pts, concat([p + [0.0155, 0, 0.175]], [for(i = [1:len(dragon_body_path) - 1]) dragon_body_path[i]]), scale = 0.9);
translate([0.125, 0, -2.73])
scale(0.009)
rotate([-60, 0, 90])
dragon_head();
translate([0, 0, -0.525])
rotate([0, -7, 0])
rotate(90)
ellipse_extrude(0.5, slices = 4, twist = 15)
scale(0.9 * 0.007)
polygon(body_shape);
}
module dragon_head() {
module palate() {
t_step = 0.15;
palate_shape = concat(
bezier_curve(0.25,
[
[31, -35], [19, 0], [8, 15], [-8, 12], [-19, 0], [-31, -35]
]
),
bezier_curve(0.25,
[[-20, -35], [-8, -20], [8, -20], [20, -35]]
)
);
palate_path = bezier_curve(t_step,
[[0, -110, 30], [0, -100, 25], [0, -80, 50], [0, -55, 130], [0, -20, -95], [0, 5, 105], [0, 10, 30], [0, 10, 25]]
);
path_extrude(palate_shape, palate_path, scale = 0);
}
module jaw() {
t_step = 0.2;
jaw_shape = concat(
bezier_curve(t_step,
[
[-20, 16], [-16, -5], [-8, -25],
[8, -25], [16, -5], [20, 16]
]
),
bezier_curve(t_step,
[[15, 14], [8, 0], [-8, 0], [-15, 14]]
)
);
jaw_path = bezier_curve(t_step,
[[0, -60, -5], [0, 5, 0], [0, 10, 0], [0, 35, 39], [0, 25, 40]]
);
path_extrude(jaw_shape, jaw_path, scale = 0);
}
module horns() {
path1 = bezier_curve(0.15,
[
[12, -40, 15],
[40, -38, 0],
[30, -60, -10],
[50, -90, -30]
]
);
shape1 = shape_circle(7, $fn = 6);
path_extrude(shape1, path1, scale = 0);
mirror([1, 0, 0])
path_extrude(shape1, path1, scale = 0);
path2 = bezier_curve(0.15,
[
[12, -42, 15],
[30, -17, 16],
[35, -20, 0],
[40, -40, -10]
]
);
shape2 = shape_circle(7, $fn = 5);
path_extrude(shape2, path2, scale = 0);
mirror([1, 0, 0])
path_extrude(shape2, path2, scale = 0);
path3 = bezier_curve(0.15,
[
[10, -40, 4],
[20, -60, 10],
[15, -70, -5],
[15, -125, 0]
]
);
shape3 = shape_circle(12, $fn = 6);
path_extrude(shape3, path3, twist = 60, scale = 0);
mirror([1, 0, 0])
path_extrude(shape3, path3, twist = 60, scale = 0);
path4 = bezier_curve(0.15,
[
[0, 10, 65],
[0, 5, 70],
[0, 10, 75],
[0, 5, 85],
]
);
path_extrude(shape_circle(5, $fn = 5), path4, scale = 0);
path5 = bezier_curve(0.15,
[
[0, 0, 65],
[0, -5, 70],
[0, 0, 70],
[0, -5, 75],
]
);
path_extrude(shape_circle(3, $fn = 5), path5, scale = 0);
path6 = bezier_curve(0.15,
[
[0, -18, 45],
[0, -20, 55],
[0, -15, 65],
[0, -20, 75],
]
);
path_extrude(shape_circle(6, $fn = 6), path6, scale = 0);
}
module tone() {
path1 = bezier_curve(0.15,
[
[0, -40, -5],
[5, 0, 15],
[-5, 5, 20],
[0, 10, 30],
]
);
shape1 = shape_circle(6, $fn = 6);
path_extrude(shape1, path1, scale = 0);
}
module eyes() {
path5 = bezier_curve(0.2,
[
[0, 0, 0],
[0, -5, 5],
[0, 0, 8],
[1, -5, 12],
]
);
module eye() {
eye_shape = shape_circle(5, $fn = 6);
translate([12, -40, 30.5])
rotate([-40, 0, 8])
scale([0.7, 1, 0.7])
union() {
rotate([-40.25, 0, 0])
path_extrude(eye_shape, path5, scale = 0);
rotate(180)
mirror([0, 0, 1])
rotate([-40.25, 0, 0])
path_extrude(eye_shape, path5, scale = 0);
}
translate([10.5, -36, 28.5])
sphere(5, $fn = 18);
}
eye();
mirror([1, 0, 0])
eye();
}
module neck() {
neck_shape = concat(
bezier_curve(0.25,
[
[31, -35], [19, 0], [8, 15], [-8, 12], [-19, 0], [-31, -35]
]
),
bezier_curve(0.25,
[[-20, -35], [-8, -20], [8, -20], [20, -35]]
)
);
translate([0, -64.5, -1])
rotate([165, 0, 0])
linear_extrude(30, scale = 0.9)
scale(0.95)
polygon(neck_shape);
}
rotate([-45, 0, 0])
union() {
rotate([45, 0, 0])
translate([0, 50, 9.5])
palate();
jaw();
horns();
tone();
eyes();
neck();
}
}
function hilbert_curve() =
let(
axiom = "A",
rules = [
["A", "B-F+CFC+F-D&F^D-F+&&CFC+F+B//"],
["B", "A&F^CFB^F^D^^-F-D^|F^B|FC^F^A//"],
["C", "|D^|F^B-F+C^F^A&&FA&F^C+F+B^F^D//"],
["D", "|CFB-F+B|FA&F^A&&FB-F+B|FC//"]
]
)
lsystem3(axiom, rules, 2, 90, 1, 0, [0, 0, 0]);