mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-05 14:27:45 +02:00
update doc
This commit is contained in:
@@ -16,7 +16,8 @@ Creates an arc path. You can pass a 2 element vector to define the central angle
|
|||||||
|
|
||||||
$fn = 24;
|
$fn = 24;
|
||||||
points = arc_path(radius = 20, angle = [45, 290]);
|
points = arc_path(radius = 20, angle = [45, 290]);
|
||||||
polyline_join(points) circle(1);
|
polyline_join(points)
|
||||||
|
circle(1);
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -25,7 +26,8 @@ Creates an arc path. You can pass a 2 element vector to define the central angle
|
|||||||
|
|
||||||
$fn = 24;
|
$fn = 24;
|
||||||
points = arc_path(radius = 20, angle = 135);
|
points = arc_path(radius = 20, angle = 135);
|
||||||
polyline_join(points) circle(1);
|
polyline_join(points)
|
||||||
|
circle(1);
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
@@ -26,7 +26,8 @@ Creates visually even spacing of n points on the surface of the sphere. Successi
|
|||||||
sphere(1, $fn = 24);
|
sphere(1, $fn = 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
polyline_join(pts) sphere(.5);
|
polyline_join(pts)
|
||||||
|
sphere(.5);
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
@@ -51,6 +51,7 @@ Given a path, the `bezier_smooth` function uses bazier curves to smooth all corn
|
|||||||
|
|
||||||
smoothed_path_pts = bezier_smooth(path_pts, round_d, closed = true);
|
smoothed_path_pts = bezier_smooth(path_pts, round_d, closed = true);
|
||||||
|
|
||||||
translate([50, 0, 0]) polygon(smoothed_path_pts);
|
translate([50, 0, 0])
|
||||||
|
polygon(smoothed_path_pts);
|
||||||
|
|
||||||

|

|
@@ -22,11 +22,11 @@ Move 2D outlines outward or inward by a given amount. Each point of the offsette
|
|||||||
[-15, 0]
|
[-15, 0]
|
||||||
];
|
];
|
||||||
|
|
||||||
color("red") polygon(bijection_offset(shape, 3));
|
color("red") polygon(bijection_offset(shape, 3));
|
||||||
color("orange") polygon(bijection_offset(shape, 2));
|
color("orange") polygon(bijection_offset(shape, 2));
|
||||||
color("yellow") polygon(bijection_offset(shape, 1));
|
color("yellow") polygon(bijection_offset(shape, 1));
|
||||||
color("green") polygon(shape);
|
color("green") polygon(shape);
|
||||||
color("blue") polygon(bijection_offset(shape, -1));
|
color("blue") polygon(bijection_offset(shape, -1));
|
||||||
color("indigo") polygon(bijection_offset(shape, -2));
|
color("indigo") polygon(bijection_offset(shape, -2));
|
||||||
color("purple") polygon(bijection_offset(shape, -3));
|
color("purple") polygon(bijection_offset(shape, -3));
|
||||||
|
|
||||||
@@ -43,7 +43,6 @@ Move 2D outlines outward or inward by a given amount. Each point of the offsette
|
|||||||
[-5, 0]
|
[-5, 0]
|
||||||
];
|
];
|
||||||
offsetted = bijection_offset(shape, 1);
|
offsetted = bijection_offset(shape, 1);
|
||||||
|
|
||||||
offsetted2 = bijection_offset(shape, 2);
|
offsetted2 = bijection_offset(shape, 2);
|
||||||
offsetted3 = bijection_offset(shape, 3);
|
offsetted3 = bijection_offset(shape, 3);
|
||||||
|
|
||||||
|
@@ -49,7 +49,8 @@
|
|||||||
// a non-uniform B-spline curve
|
// a non-uniform B-spline curve
|
||||||
knots = [0, 1/8, 1/4, 1/2, 3/4, 4/5, 1];
|
knots = [0, 1/8, 1/4, 1/2, 3/4, 4/5, 1];
|
||||||
|
|
||||||
color("red") for(p = points) {
|
color("red")
|
||||||
|
for(p = points) {
|
||||||
translate(p)
|
translate(p)
|
||||||
sphere(0.5);
|
sphere(0.5);
|
||||||
}
|
}
|
||||||
@@ -73,7 +74,8 @@
|
|||||||
// For a clamped B-spline curve, the first `degree + 1` and the last `degree + 1` knots must be identical.
|
// For a clamped B-spline curve, the first `degree + 1` and the last `degree + 1` knots must be identical.
|
||||||
knots = [0, 0, 0, 1, 2, 2, 2];
|
knots = [0, 0, 0, 1, 2, 2, 2];
|
||||||
|
|
||||||
color("red") for(p = points) {
|
color("red")
|
||||||
|
for(p = points) {
|
||||||
translate(p)
|
translate(p)
|
||||||
sphere(0.5);
|
sphere(0.5);
|
||||||
}
|
}
|
||||||
|
@@ -23,10 +23,10 @@ Computes contour polygons by applying [marching squares](https://en.wikipedia.or
|
|||||||
|
|
||||||
points = [
|
points = [
|
||||||
for(y = [min_value:resolution:max_value])
|
for(y = [min_value:resolution:max_value])
|
||||||
[
|
[
|
||||||
for(x = [min_value:resolution:max_value])
|
for(x = [min_value:resolution:max_value])
|
||||||
[x, y, f(x, y)]
|
[x, y, f(x, y)]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
sf_thicken(points, 1);
|
sf_thicken(points, 1);
|
||||||
|
@@ -16,26 +16,21 @@ returns a new list with all sub-list elements concatenated into it recursively u
|
|||||||
vt = [[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]];
|
vt = [[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]];
|
||||||
|
|
||||||
assert(
|
assert(
|
||||||
flat([1, 2, [3, 4]]) ==
|
flat([1, 2, [3, 4]]) == [1, 2, 3, 4]
|
||||||
[1, 2, 3, 4]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
assert(
|
assert(
|
||||||
flat([[1, 2], [3, 4]]) ==
|
flat([[1, 2], [3, 4]]) == [1, 2, 3, 4]
|
||||||
[1, 2, 3, 4]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
assert(
|
assert(
|
||||||
flat([[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]]) ==
|
flat([[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]]) == [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]
|
||||||
[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
assert(
|
assert(
|
||||||
flat([[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]], 2) ==
|
flat([[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]], 2) == [[1, 2], [3, 4], [5, 6], [7, 8]]
|
||||||
[[1, 2], [3, 4], [5, 6], [7, 8]]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
assert(
|
assert(
|
||||||
flat([[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]], 3) ==
|
flat([[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]], 3) == [1, 2, 3, 4, 5, 6, 7, 8]
|
||||||
[1, 2, 3, 4, 5, 6, 7, 8]
|
|
||||||
);
|
);
|
||||||
|
@@ -39,9 +39,9 @@ This function maps keys to values. You can use the following to process the retu
|
|||||||
m3 = hashmap_del(m2, "k1");
|
m3 = hashmap_del(m2, "k1");
|
||||||
assert(hashmap_get(m3, "k1") == undef);
|
assert(hashmap_get(m3, "k1") == undef);
|
||||||
|
|
||||||
echo(hashmap_keys(m3)); // a list contains "k2", "k2", "k3"
|
assert(hashmap_keys(m3) == ["k2", "k3", "k4"]);
|
||||||
echo(hashmap_values(m3)); // a list contains 20, 30, 40
|
assert(hashmap_values(m3) == [20, 30, 40]);
|
||||||
echo(hashmap_entries(m3)); // a list contains ["k2", 20], ["k3", 30], ["k4", 40]
|
assert(hashmap_entries(m3) == [["k2", 20], ["k3", 30], ["k4", 40]]);
|
||||||
|
|
||||||
Want to simulate class-based OO in OpenSCAD? Here's my experiment.
|
Want to simulate class-based OO in OpenSCAD? Here's my experiment.
|
||||||
|
|
||||||
|
@@ -35,4 +35,4 @@ This function models the mathematical set, backed by a hash table. You can use t
|
|||||||
s3 = hashset_del(s2, 2);
|
s3 = hashset_del(s2, 2);
|
||||||
assert(!hashset_has(s3, 2));
|
assert(!hashset_has(s3, 2));
|
||||||
|
|
||||||
echo(hashset_elems(s3)); // a list contains 1, 3, 4, 5, 9
|
assert(hashset_elems(s3) == [1, 3, 4, 5, 9]);
|
||||||
|
@@ -14,5 +14,5 @@ Returns a list containing all elements in a [util/set/hashset](https://openhome.
|
|||||||
use <util/set/hashset_elems.scad>;
|
use <util/set/hashset_elems.scad>;
|
||||||
|
|
||||||
s = hashset([1, 2, 3, 4, 5]);
|
s = hashset([1, 2, 3, 4, 5]);
|
||||||
echo(hashset_elems(s)); // a list contains 1, 2, 3, 4, 5
|
assert(hashset_elems(s) == [1, 2, 3, 4, 5]);
|
||||||
|
|
||||||
|
@@ -27,7 +27,8 @@ Gets all points on the path of a spiral around a cylinder. Its `$fa`, `$fs` and
|
|||||||
);
|
);
|
||||||
|
|
||||||
for(p = points) {
|
for(p = points) {
|
||||||
translate(p) sphere(5);
|
translate(p)
|
||||||
|
sphere(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
polyline_join(points)
|
polyline_join(points)
|
||||||
|
@@ -10,7 +10,10 @@ Hollows out a 2D object.
|
|||||||
|
|
||||||
use <hollow_out.scad>;
|
use <hollow_out.scad>;
|
||||||
|
|
||||||
hollow_out(shell_thickness = 1) circle(r = 3, $fn = 48);
|
hollow_out(shell_thickness = 1)
|
||||||
hollow_out(shell_thickness = 1) square([10, 5]);
|
circle(r = 3, $fn = 48);
|
||||||
|
|
||||||
|
hollow_out(shell_thickness = 1)
|
||||||
|
square([10, 5]);
|
||||||
|
|
||||||

|

|
||||||
|
@@ -20,10 +20,10 @@ Checks whether a point is on a line.
|
|||||||
[10, 10]
|
[10, 10]
|
||||||
];
|
];
|
||||||
|
|
||||||
echo(in_polyline(pts, [-2, -3])); // false
|
assert(!in_polyline(pts, [-2, -3]));
|
||||||
echo(in_polyline(pts, [5, 0])); // true
|
assert(in_polyline(pts, [5, 0]));
|
||||||
echo(in_polyline(pts, [10, 5])); // true
|
assert(in_polyline(pts, [10, 5]));
|
||||||
echo(in_polyline(pts, [10, 15])); // false
|
assert(!in_polyline(pts, [10, 15]));
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ Checks whether a point is on a line.
|
|||||||
[20, 10, 10]
|
[20, 10, 10]
|
||||||
];
|
];
|
||||||
|
|
||||||
echo(in_polyline(pts, [10, 0, 10])); // true
|
assert(in_polyline(pts, [10, 0, 10]));
|
||||||
echo(in_polyline(pts, [15, 0, 10])); // true
|
assert(in_polyline(pts, [15, 0, 10]));
|
||||||
echo(in_polyline(pts, [15, 1, 10])); // false
|
assert(!in_polyline(pts, [15, 1, 10]));
|
||||||
echo(in_polyline(pts, [20, 11, 10])); // false
|
assert(!in_polyline(pts, [20, 11, 10]));
|
@@ -16,8 +16,8 @@ Generate a 4x4 transformation matrix which can pass into `multmatrix` to mirror
|
|||||||
cube([3, 2, 1]);
|
cube([3, 2, 1]);
|
||||||
|
|
||||||
multmatrix(m_mirror([1, 1, 0]))
|
multmatrix(m_mirror([1, 1, 0]))
|
||||||
rotate([0, 0, 10])
|
rotate([0, 0, 10])
|
||||||
cube([3, 2, 1]);
|
cube([3, 2, 1]);
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
@@ -19,8 +19,8 @@ Generate a 4x4 transformation matrix which can pass into `multmatrix` to rotate
|
|||||||
hull() {
|
hull() {
|
||||||
sphere(1);
|
sphere(1);
|
||||||
multmatrix(m_rotation(a))
|
multmatrix(m_rotation(a))
|
||||||
translate(point)
|
translate(point)
|
||||||
sphere(1);
|
sphere(1);
|
||||||
}
|
}
|
||||||
|
|
||||||

|

|
||||||
@@ -32,14 +32,14 @@ Generate a 4x4 transformation matrix which can pass into `multmatrix` to rotate
|
|||||||
hull() {
|
hull() {
|
||||||
sphere(1);
|
sphere(1);
|
||||||
translate(v)
|
translate(v)
|
||||||
sphere(1);
|
sphere(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
p = [10, 10, 0];
|
p = [10, 10, 0];
|
||||||
for(i = [0:20:340]) {
|
for(i = [0:20:340]) {
|
||||||
multmatrix(m_rotation(a = i, v = v))
|
multmatrix(m_rotation(a = i, v = v))
|
||||||
translate(p)
|
translate(p)
|
||||||
sphere(1);
|
sphere(1);
|
||||||
}
|
}
|
||||||
|
|
||||||

|

|
@@ -14,8 +14,8 @@ Generate a 4x4 transformation matrix which can pass into `multmatrix` to scale i
|
|||||||
|
|
||||||
cube(10);
|
cube(10);
|
||||||
translate([15, 0, 0])
|
translate([15, 0, 0])
|
||||||
multmatrix(m_scaling([0.5, 1, 2]))
|
multmatrix(m_scaling([0.5, 1, 2]))
|
||||||
cube(10);
|
cube(10);
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
@@ -18,10 +18,12 @@ Generate a 4x4 transformation matrix which can pass into `multmatrix` to shear a
|
|||||||
multmatrix(m_shearing(sx = [1, 0]))
|
multmatrix(m_shearing(sx = [1, 0]))
|
||||||
cube(1);
|
cube(1);
|
||||||
|
|
||||||
translate([2, 0, 0]) multmatrix(m_shearing(sx = [0, 1]))
|
translate([2, 0, 0])
|
||||||
|
multmatrix(m_shearing(sx = [0, 1]))
|
||||||
cube(1);
|
cube(1);
|
||||||
|
|
||||||
translate([4, 0, 0]) multmatrix(m_shearing(sx = [1, 1]))
|
translate([4, 0, 0])
|
||||||
|
multmatrix(m_shearing(sx = [1, 1]))
|
||||||
cube(1);
|
cube(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,10 +31,12 @@ Generate a 4x4 transformation matrix which can pass into `multmatrix` to shear a
|
|||||||
multmatrix(m_shearing(sy = [1, 0]))
|
multmatrix(m_shearing(sy = [1, 0]))
|
||||||
cube(1);
|
cube(1);
|
||||||
|
|
||||||
translate([2, 0, 0]) multmatrix(m_shearing(sy = [0, 1]))
|
translate([2, 0, 0])
|
||||||
|
multmatrix(m_shearing(sy = [0, 1]))
|
||||||
cube(1);
|
cube(1);
|
||||||
|
|
||||||
translate([4, 0, 0]) multmatrix(m_shearing(sy = [1, 1]))
|
translate([4, 0, 0])
|
||||||
|
multmatrix(m_shearing(sy = [1, 1]))
|
||||||
cube(1);
|
cube(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,10 +44,12 @@ Generate a 4x4 transformation matrix which can pass into `multmatrix` to shear a
|
|||||||
multmatrix(m_shearing(sz = [1, 0]))
|
multmatrix(m_shearing(sz = [1, 0]))
|
||||||
cube(1);
|
cube(1);
|
||||||
|
|
||||||
translate([2, 0, 0]) multmatrix(m_shearing(sz = [0, 1]))
|
translate([2, 0, 0])
|
||||||
|
multmatrix(m_shearing(sz = [0, 1]))
|
||||||
cube(1);
|
cube(1);
|
||||||
|
|
||||||
translate([4, 0, 0]) multmatrix(m_shearing(sz = [1, 1]))
|
translate([4, 0, 0])
|
||||||
|
multmatrix(m_shearing(sz = [1, 1]))
|
||||||
cube(1);
|
cube(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -19,7 +19,12 @@ Given a 2D path, this function constructs a mid-point smoothed version by joinin
|
|||||||
taiwan = shape_taiwan(50);
|
taiwan = shape_taiwan(50);
|
||||||
smoothed = midpt_smooth(taiwan, 20, true);
|
smoothed = midpt_smooth(taiwan, 20, true);
|
||||||
|
|
||||||
translate([0, 0, 0]) polyline_join(taiwan) circle(.125);
|
translate([0, 0, 0])
|
||||||
#translate([10, 0, 0]) polyline_join(smoothed) circle(.125);
|
polyline_join(taiwan)
|
||||||
|
circle(.125);
|
||||||
|
|
||||||
|
#translate([10, 0, 0])
|
||||||
|
polyline_join(smoothed)
|
||||||
|
circle(.125);
|
||||||
|
|
||||||

|

|
@@ -41,11 +41,9 @@ The cell data is seperated from views. You can use cell data to construct [diffe
|
|||||||
cells = mz_square_cells(rows, columns);
|
cells = mz_square_cells(rows, columns);
|
||||||
|
|
||||||
for(cell = cells) {
|
for(cell = cells) {
|
||||||
x = cell[0];
|
|
||||||
y = cell[1];
|
|
||||||
type = cell[2];
|
type = cell[2];
|
||||||
|
|
||||||
translate([x, y] * cell_width) {
|
translate([cell.x, cell.y] * cell_width) {
|
||||||
if(type == TOP_WALL || type == TOP_RIGHT_WALL) {
|
if(type == TOP_WALL || type == TOP_RIGHT_WALL) {
|
||||||
line2d([0, cell_width], [cell_width, cell_width], wall_thickness);
|
line2d([0, cell_width], [cell_width, cell_width], wall_thickness);
|
||||||
}
|
}
|
||||||
|
@@ -68,12 +68,10 @@ It's a helper for initializing cell data of a maze.
|
|||||||
// Mask
|
// Mask
|
||||||
mask_width = cell_width + wall_thickness;
|
mask_width = cell_width + wall_thickness;
|
||||||
translate([-wall_thickness / 2, -wall_thickness / 2])
|
translate([-wall_thickness / 2, -wall_thickness / 2])
|
||||||
for(i = [0:rows - 1]) {
|
for(i = [0:rows - 1], j = [0:columns - 1]) {
|
||||||
for(j = [0:columns - 1]) {
|
if(mask[i][j] == 0) {
|
||||||
if(mask[i][j] == 0) {
|
translate([cell_width * j, cell_width * (rows - i - 1)])
|
||||||
translate([cell_width * j, cell_width * (rows - i - 1)])
|
square(mask_width);
|
||||||
square(mask_width);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -42,31 +42,29 @@ The value of `type` is the wall type of the cell. It can be `0`, `1`, `2` or `3`
|
|||||||
maze = mz_theta_cells(rows, beginning_number);
|
maze = mz_theta_cells(rows, beginning_number);
|
||||||
|
|
||||||
// draw cell walls
|
// draw cell walls
|
||||||
for(rows = maze) {
|
for(rows = maze, cell = rows) {
|
||||||
for(cell = rows) {
|
ri = cell[0];
|
||||||
ri = cell[0];
|
ci = cell[1];
|
||||||
ci = cell[1];
|
type = cell[2];
|
||||||
type = cell[2];
|
thetaStep = 360 / len(maze[ri]);
|
||||||
thetaStep = 360 / len(maze[ri]);
|
innerR = (ri + 1) * cell_width;
|
||||||
innerR = (ri + 1) * cell_width;
|
outerR = (ri + 2) * cell_width;
|
||||||
outerR = (ri + 2) * cell_width;
|
theta1 = thetaStep * ci;
|
||||||
theta1 = thetaStep * ci;
|
theta2 = thetaStep * (ci + 1);
|
||||||
theta2 = thetaStep * (ci + 1);
|
|
||||||
|
innerVt1 = vt_from_angle(theta1, innerR);
|
||||||
innerVt1 = vt_from_angle(theta1, innerR);
|
innerVt2 = vt_from_angle(theta2, innerR);
|
||||||
innerVt2 = vt_from_angle(theta2, innerR);
|
outerVt2 = vt_from_angle(theta2, outerR);
|
||||||
outerVt2 = vt_from_angle(theta2, outerR);
|
|
||||||
|
if(type == INWARD_WALL || type == INWARD_CCW_WALL) {
|
||||||
if(type == INWARD_WALL || type == INWARD_CCW_WALL) {
|
polyline_join([innerVt1, innerVt2])
|
||||||
polyline_join([innerVt1, innerVt2])
|
circle(wall_thickness / 2);
|
||||||
circle(wall_thickness / 2);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(type == CCW_WALL || type == INWARD_CCW_WALL) {
|
if(type == CCW_WALL || type == INWARD_CCW_WALL) {
|
||||||
polyline_join([innerVt2, outerVt2])
|
polyline_join([innerVt2, outerVt2])
|
||||||
circle(wall_thickness / 2);
|
circle(wall_thickness / 2);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// outmost walls
|
// outmost walls
|
||||||
|
@@ -23,31 +23,29 @@ It's a helper for getting data from a theta-maze cell.
|
|||||||
function vt_from_angle(theta, r) = [r * cos(theta), r * sin(theta)];
|
function vt_from_angle(theta, r) = [r * cos(theta), r * sin(theta)];
|
||||||
|
|
||||||
maze = mz_theta_cells(rows, beginning_number);
|
maze = mz_theta_cells(rows, beginning_number);
|
||||||
for(rows = maze) {
|
for(rows = maze, cell = rows) {
|
||||||
for(cell = rows) {
|
ri = mz_theta_get(cell, "r");
|
||||||
ri = mz_theta_get(cell, "r");
|
ci = mz_theta_get(cell, "c");
|
||||||
ci = mz_theta_get(cell, "c");
|
type = mz_theta_get(cell, "t");
|
||||||
type = mz_theta_get(cell, "t");
|
thetaStep = 360 / len(maze[ri]);
|
||||||
thetaStep = 360 / len(maze[ri]);
|
innerR = (ri + 1) * cell_width;
|
||||||
innerR = (ri + 1) * cell_width;
|
outerR = (ri + 2) * cell_width;
|
||||||
outerR = (ri + 2) * cell_width;
|
theta1 = thetaStep * ci;
|
||||||
theta1 = thetaStep * ci;
|
theta2 = thetaStep * (ci + 1);
|
||||||
theta2 = thetaStep * (ci + 1);
|
|
||||||
|
innerVt1 = vt_from_angle(theta1, innerR);
|
||||||
innerVt1 = vt_from_angle(theta1, innerR);
|
innerVt2 = vt_from_angle(theta2, innerR);
|
||||||
innerVt2 = vt_from_angle(theta2, innerR);
|
outerVt2 = vt_from_angle(theta2, outerR);
|
||||||
outerVt2 = vt_from_angle(theta2, outerR);
|
|
||||||
|
if(type == "INWARD_WALL" || type == "INWARD_CCW_WALL") {
|
||||||
if(type == "INWARD_WALL" || type == "INWARD_CCW_WALL") {
|
polyline_join([innerVt1, innerVt2])
|
||||||
polyline_join([innerVt1, innerVt2])
|
circle(wall_thickness / 2);
|
||||||
circle(wall_thickness / 2);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(type == "CCW_WALL" || type == "INWARD_CCW_WALL") {
|
if(type == "CCW_WALL" || type == "INWARD_CCW_WALL") {
|
||||||
polyline_join([innerVt2, outerVt2])
|
polyline_join([innerVt2, outerVt2])
|
||||||
circle(wall_thickness / 2);
|
circle(wall_thickness / 2);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
thetaStep = 360 / len(maze[rows - 1]);
|
thetaStep = 360 / len(maze[rows - 1]);
|
||||||
|
@@ -26,9 +26,8 @@ It's an implementation of [Worley noise](https://en.wikipedia.org/wiki/Worley_no
|
|||||||
|
|
||||||
feature_points = [for(pt_angle = pts_angles) pt_angle[0] + half_size];
|
feature_points = [for(pt_angle = pts_angles) pt_angle[0] + half_size];
|
||||||
noised = [
|
noised = [
|
||||||
for(y = [0:size.y - 1])
|
for(y = [0:size.y - 1], x = [0:size.x - 1])
|
||||||
for(x = [0:size.x - 1])
|
[x, y, nz_cell(feature_points, [x, y])]
|
||||||
[x, y, nz_cell(feature_points, [x, y])]
|
|
||||||
];
|
];
|
||||||
|
|
||||||
max_dist = max([for(n = noised) n[2]]);
|
max_dist = max([for(n = noised) n[2]]);
|
||||||
|
@@ -18,15 +18,13 @@ Returns the 3D [Perlin noise](https://en.wikipedia.org/wiki/Perlin_noise) value
|
|||||||
|
|
||||||
seed = rand(0, 255);
|
seed = rand(0, 255);
|
||||||
noised = [
|
noised = [
|
||||||
for(z = [0:.2:5])
|
for(z = [0:.2:5], y = [0:.2:5], x = [0:.2:5])
|
||||||
for(y = [0:.2:5])
|
[x, y, z, nz_perlin3(x, y, z, seed)]
|
||||||
for(x = [0:.2:5])
|
|
||||||
[x, y, z, nz_perlin3(x, y, z, seed)]
|
|
||||||
];
|
];
|
||||||
|
|
||||||
for(nz = noised) {
|
for(nz = noised) {
|
||||||
if(nz[3] > 0.2) {
|
if(nz[3] > 0.2) {
|
||||||
translate([nz[0], nz[1], nz[2]])
|
translate([nz.x, nz.y, nz.z])
|
||||||
cube(.2);
|
cube(.2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -27,11 +27,11 @@ Returns 3D [Perlin noise](https://en.wikipedia.org/wiki/Perlin_noise) values at
|
|||||||
|
|
||||||
points_with_h = [
|
points_with_h = [
|
||||||
for(ri = [0:len(points) - 1])
|
for(ri = [0:len(points) - 1])
|
||||||
let(ns = nz_perlin2s(points[ri], seed))
|
let(ns = nz_perlin2s(points[ri], seed))
|
||||||
[
|
[
|
||||||
for(ci = [0:len(ns) - 1])
|
for(ci = [0:len(ns) - 1])
|
||||||
[points[ri][ci][0], points[ri][ci][1], ns[ci] + 1]
|
[points[ri][ci][0], points[ri][ci][1], ns[ci] + 1]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
h_scale = 1.5;
|
h_scale = 1.5;
|
||||||
@@ -39,7 +39,7 @@ Returns 3D [Perlin noise](https://en.wikipedia.org/wiki/Perlin_noise) values at
|
|||||||
for(i = [0:len(row) - 1]) {
|
for(i = [0:len(row) - 1]) {
|
||||||
p = row[i];
|
p = row[i];
|
||||||
pts = [
|
pts = [
|
||||||
for(z = [0:.2:p[2] * h_scale]) [p[0], p[1], z]
|
for(z = [0:.2:p[2] * h_scale]) [p.x, p.y, z]
|
||||||
];
|
];
|
||||||
noise = nz_perlin3s(pts, seed);
|
noise = nz_perlin3s(pts, seed);
|
||||||
for(j = [0:len(pts) - 1]) {
|
for(j = [0:len(pts) - 1]) {
|
||||||
|
@@ -27,9 +27,8 @@ It divides the space into grids. The nucleus of each cell is randomly placed in
|
|||||||
seed = 51;
|
seed = 51;
|
||||||
|
|
||||||
points = [
|
points = [
|
||||||
for(y = [0:size.y - 1])
|
for(y = [0:size.y - 1], x = [0:size.x - 1])
|
||||||
for(x = [0:size.x - 1])
|
[x, y]
|
||||||
[x, y]
|
|
||||||
];
|
];
|
||||||
|
|
||||||
cells = [for(p = points) nz_worley2(p.x, p.y, seed, grid_w, dist)];
|
cells = [for(p = points) nz_worley2(p.x, p.y, seed, grid_w, dist)];
|
||||||
@@ -43,7 +42,7 @@ It divides the space into grids. The nucleus of each cell is randomly placed in
|
|||||||
square(1);
|
square(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
cells_pts = dedup([for(c = cells) [c[0], c[1]]]);
|
cells_pts = dedup([for(c = cells) [c.x, c.y]]);
|
||||||
for(p = cells_pts) {
|
for(p = cells_pts) {
|
||||||
translate(p)
|
translate(p)
|
||||||
linear_extrude(max_dist)
|
linear_extrude(max_dist)
|
||||||
|
@@ -25,9 +25,8 @@ It divides the space into grids. The nucleus of each cell is randomly placed in
|
|||||||
seed = 51;
|
seed = 51;
|
||||||
|
|
||||||
points = [
|
points = [
|
||||||
for(y = [0:size.y - 1])
|
for(y = [0:size.y - 1], x = [0:size.x - 1])
|
||||||
for(x = [0:size.x - 1])
|
[x, y]
|
||||||
[x, y]
|
|
||||||
];
|
];
|
||||||
|
|
||||||
cells = nz_worley2s(points, seed, grid_w, dist);
|
cells = nz_worley2s(points, seed, grid_w, dist);
|
||||||
|
@@ -26,7 +26,7 @@ It divides the space into grids. The nucleus of each cell is randomly placed in
|
|||||||
cells = nz_worley3s(points, seed, grid_w, dist);
|
cells = nz_worley3s(points, seed, grid_w, dist);
|
||||||
|
|
||||||
for(i = [0:len(cells) - 1]) {
|
for(i = [0:len(cells) - 1]) {
|
||||||
c = (norm([cells[i][0], cells[i][1], cells[i][2]]) % 20) / 20;
|
c = (norm([cells[i].x, cells[i].y, cells[i].z]) % 20) / 20;
|
||||||
color([c, c, c])
|
color([c, c, c])
|
||||||
translate(points[i])
|
translate(points[i])
|
||||||
cube(1);
|
cube(1);
|
||||||
|
@@ -255,12 +255,13 @@ So, which is the correct method? Both methods are correct when you provide only
|
|||||||
shape_pentagram_pts = shape_pentagram(star_radius);
|
shape_pentagram_pts = shape_pentagram(star_radius);
|
||||||
|
|
||||||
// not closed perfectly
|
// not closed perfectly
|
||||||
translate([-8, 0, 0]) path_extrude(
|
translate([-8, 0, 0])
|
||||||
shape_pentagram_pts,
|
path_extrude(
|
||||||
[each pts, pts[0]],
|
shape_pentagram_pts,
|
||||||
closed = true,
|
[each pts, pts[0]],
|
||||||
method = "AXIS_ANGLE"
|
closed = true,
|
||||||
);
|
method = "AXIS_ANGLE"
|
||||||
|
);
|
||||||
|
|
||||||
// adjust it
|
// adjust it
|
||||||
path_extrude(
|
path_extrude(
|
||||||
@@ -272,12 +273,13 @@ So, which is the correct method? Both methods are correct when you provide only
|
|||||||
);
|
);
|
||||||
|
|
||||||
// "EULER_ANGLE" is easy in this situation
|
// "EULER_ANGLE" is easy in this situation
|
||||||
translate([0, 8, 0]) path_extrude(
|
translate([0, 8, 0])
|
||||||
shape_pentagram_pts,
|
path_extrude(
|
||||||
[each pts, pts[0]],
|
shape_pentagram_pts,
|
||||||
closed = true,
|
[each pts, pts[0]],
|
||||||
method = "EULER_ANGLE"
|
closed = true,
|
||||||
);
|
method = "EULER_ANGLE"
|
||||||
|
);
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
@@ -45,7 +45,6 @@ You can use any point as the first point of the edge path. Just remember that yo
|
|||||||
use <sweep.scad>;
|
use <sweep.scad>;
|
||||||
use <bezier_curve.scad>;
|
use <bezier_curve.scad>;
|
||||||
|
|
||||||
|
|
||||||
taiwan = shape_taiwan(100);
|
taiwan = shape_taiwan(100);
|
||||||
fst_pt = [13, 0, 0];
|
fst_pt = [13, 0, 0];
|
||||||
|
|
||||||
|
@@ -13,8 +13,10 @@ Creates a pie (circular sector). Its `$fa`, `$fs` and `$fn` are consistent with
|
|||||||
use <pie.scad>;
|
use <pie.scad>;
|
||||||
|
|
||||||
pie(radius = 20, angle = [210, 310]);
|
pie(radius = 20, angle = [210, 310]);
|
||||||
translate([-15, 0, 0]) pie(radius = 20, angle = [45, 135]);
|
translate([-15, 0, 0])
|
||||||
translate([15, 0, 0]) pie(radius = 20, angle = [45, 135], $fn = 12);
|
pie(radius = 20, angle = [45, 135]);
|
||||||
|
translate([15, 0, 0])
|
||||||
|
pie(radius = 20, angle = [45, 135], $fn = 12);
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
@@ -17,9 +17,8 @@ Creates a [superellipsoid](https://en.wikipedia.org/wiki/Superellipsoid).
|
|||||||
|
|
||||||
step = 0.5;
|
step = 0.5;
|
||||||
|
|
||||||
for(e = [0:step:4]) {
|
for(e = [0:step:4], n = [0:step:4]) {
|
||||||
for(n = [0:step:4])
|
translate([e / step, n / step] * 3)
|
||||||
translate([e / step, n / step] * 3)
|
|
||||||
superellipsoid(e, n);
|
superellipsoid(e, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -23,16 +23,23 @@ Creates a polyline from a list of `[x, y]` coordinates. When the end points are
|
|||||||
use <polyline2d.scad>;
|
use <polyline2d.scad>;
|
||||||
|
|
||||||
$fn = 24;
|
$fn = 24;
|
||||||
polyline2d(points = [[1, 2], [-5, -4], [-5, 3], [5, 5]], width = 1,
|
polyline2d(
|
||||||
endingStyle = "CAP_ROUND");
|
points = [[1, 2], [-5, -4], [-5, 3], [5, 5]],
|
||||||
|
width = 1,
|
||||||
|
endingStyle = "CAP_ROUND"
|
||||||
|
);
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
use <polyline2d.scad>;
|
use <polyline2d.scad>;
|
||||||
|
|
||||||
$fn = 24;
|
$fn = 24;
|
||||||
polyline2d(points = [[1, 2], [-5, -4], [-5, 3], [5, 5]], width = 1,
|
polyline2d(
|
||||||
startingStyle = "CAP_ROUND", endingStyle = "CAP_ROUND");
|
points = [[1, 2], [-5, -4], [-5, 3], [5, 5]],
|
||||||
|
width = 1,
|
||||||
|
startingStyle = "CAP_ROUND",
|
||||||
|
endingStyle = "CAP_ROUND"
|
||||||
|
);
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
@@ -21,12 +21,10 @@ Transforms a point inside a rectangle to a point of an arc.
|
|||||||
radius = 20;
|
radius = 20;
|
||||||
angle = 180;
|
angle = 180;
|
||||||
|
|
||||||
for(i = [0:len(t) - 1]) {
|
for(i = [0:len(t) - 1], pt = vx_ascii(t[i], invert = true)) {
|
||||||
for(pt = vx_ascii(t[i], invert = true)) {
|
bended = ptf_bend(size, pt + [i * 8, 0], radius, angle);
|
||||||
bended = ptf_bend(size, pt + [i * 8, 0], radius, angle);
|
translate(bended)
|
||||||
translate(bended)
|
sphere(0.5, $fn = 24);
|
||||||
sphere(0.5, $fn = 24);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||

|

|
||||||
|
@@ -22,8 +22,8 @@ Rotates a point `a` degrees around the axis of the coordinate system or an arbit
|
|||||||
hull() {
|
hull() {
|
||||||
sphere(1);
|
sphere(1);
|
||||||
translate(ptf_rotate(point, a))
|
translate(ptf_rotate(point, a))
|
||||||
rotate(a)
|
rotate(a)
|
||||||
sphere(1);
|
sphere(1);
|
||||||
}
|
}
|
||||||
|
|
||||||

|

|
||||||
@@ -57,7 +57,7 @@ Rotates a point `a` degrees around the axis of the coordinate system or an arbit
|
|||||||
hull() {
|
hull() {
|
||||||
sphere(1);
|
sphere(1);
|
||||||
translate(v)
|
translate(v)
|
||||||
sphere(1);
|
sphere(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
p = [10, 10, 0];
|
p = [10, 10, 0];
|
||||||
|
@@ -27,18 +27,18 @@ It solidifies two square surfaces, described by a m * n list of `[x, y, z]`s.
|
|||||||
|
|
||||||
surface1 = [
|
surface1 = [
|
||||||
for(y = [min_value:resolution:max_value])
|
for(y = [min_value:resolution:max_value])
|
||||||
[
|
[
|
||||||
for(x = [min_value:resolution:max_value])
|
for(x = [min_value:resolution:max_value])
|
||||||
[x, y, f(x, y) + 100]
|
[x, y, f(x, y) + 100]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
surface2 = [
|
surface2 = [
|
||||||
for(y = [min_value:resolution:max_value])
|
for(y = [min_value:resolution:max_value])
|
||||||
[
|
[
|
||||||
for(x = [min_value:resolution:max_value])
|
for(x = [min_value:resolution:max_value])
|
||||||
[x, y, -f(x, y) - 100]
|
[x, y, -f(x, y) - 100]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
sf_solidify(surface1, surface2);
|
sf_solidify(surface1, surface2);
|
||||||
|
@@ -29,27 +29,25 @@ It solidifies two surfaces with triangular mesh.
|
|||||||
use <surface/sf_solidifyT.scad>;
|
use <surface/sf_solidifyT.scad>;
|
||||||
|
|
||||||
thickness = .2;
|
thickness = .2;
|
||||||
a_step = 10;
|
a_step = 15;
|
||||||
r_step = 0.2;
|
r_step = 0.2;
|
||||||
scale = 100;
|
scale = 100;
|
||||||
|
|
||||||
function f(x, y) = (pow(y,2)/pow(2, 2))-(pow(x,2)/pow(2, 2));
|
function f(x, y) = (y ^ 2 - x ^ 2) / 4;
|
||||||
|
|
||||||
pts2d = [
|
pts2d = [
|
||||||
for(a = [a_step:a_step:360])
|
for(a = [a_step:a_step:360], r = [r_step:r_step:2])
|
||||||
for(r = [r_step:r_step:2])
|
let(
|
||||||
let(
|
x = r * cos(a),
|
||||||
x = round(r * cos(a) * 100) / 100,
|
y = r * sin(a)
|
||||||
y = round(r * sin(a) * 100) / 100
|
)
|
||||||
)
|
[x, y]
|
||||||
[x, y]
|
|
||||||
];
|
];
|
||||||
|
|
||||||
points1 = [for(p = pts2d) scale * [p.x, p.y, f(p.x, p.y)]];
|
points1 = [for(p = pts2d) scale * [p.x, p.y, f(p.x, p.y)]];
|
||||||
points2 = [for(p = points1) [p.x, p.y, p.z - scale * thickness]];
|
points2 = [for(p = points1) [p.x, p.y, p.z - scale * thickness]];
|
||||||
triangles = tri_delaunay(pts2d);
|
triangles = tri_delaunay(pts2d);
|
||||||
|
|
||||||
|
|
||||||
sf_solidifyT(points1, points2, triangles);
|
sf_solidifyT(points1, points2, triangles);
|
||||||
|
|
||||||

|

|
@@ -28,10 +28,8 @@ It thickens a surface, described by a m * n list of `[x, y, z]`s.
|
|||||||
use <surface/sf_thicken.scad>;
|
use <surface/sf_thicken.scad>;
|
||||||
|
|
||||||
function f(x, y) =
|
function f(x, y) =
|
||||||
30 * (
|
let(leng = norm([x, y]))
|
||||||
cos(sqrt(pow(x, 2) + pow(y, 2))) +
|
30 * (cos(leng) + cos(3 * leng));
|
||||||
cos(3 * sqrt(pow(x, 2) + pow(y, 2)))
|
|
||||||
);
|
|
||||||
|
|
||||||
thickness = 3;
|
thickness = 3;
|
||||||
min_value = -200;
|
min_value = -200;
|
||||||
@@ -40,10 +38,10 @@ It thickens a surface, described by a m * n list of `[x, y, z]`s.
|
|||||||
|
|
||||||
surface1 = [
|
surface1 = [
|
||||||
for(y = [min_value:resolution:max_value])
|
for(y = [min_value:resolution:max_value])
|
||||||
[
|
[
|
||||||
for(x = [min_value:resolution:max_value])
|
for(x = [min_value:resolution:max_value])
|
||||||
[x, y, f(x, y) + 100]
|
[x, y, f(x, y) + 100]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
sf_thicken(surface1, thickness);
|
sf_thicken(surface1, thickness);
|
||||||
|
|
||||||
@@ -60,10 +58,10 @@ It thickens a surface, described by a m * n list of `[x, y, z]`s.
|
|||||||
|
|
||||||
surface1 = [
|
surface1 = [
|
||||||
for(y = [min_value:resolution:max_value])
|
for(y = [min_value:resolution:max_value])
|
||||||
[
|
[
|
||||||
for(x = [min_value:resolution:max_value])
|
for(x = [min_value:resolution:max_value])
|
||||||
[x, y, f(x, y) + 100]
|
[x, y, f(x, y) + 100]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
sf_thicken(surface1, thickness, direction = [1, 1, -1]);
|
sf_thicken(surface1, thickness, direction = [1, 1, -1]);
|
||||||
|
|
||||||
|
@@ -18,7 +18,7 @@ It thickens a surface with triangular mesh.
|
|||||||
a_step = 15;
|
a_step = 15;
|
||||||
r_step = 0.2;
|
r_step = 0.2;
|
||||||
|
|
||||||
function f(x, y) = (y^2 - x^2) / 4;
|
function f(x, y) = (y ^ 2 - x ^ 2) / 4;
|
||||||
|
|
||||||
points = [
|
points = [
|
||||||
for(a = [a_step:a_step:360], r = [r_step:r_step:2])
|
for(a = [a_step:a_step:360], r = [r_step:r_step:2])
|
||||||
|
@@ -23,9 +23,9 @@ Sometimes you need all points on the path of a circle. Here's the function. Its
|
|||||||
step_angle = 360 / leng;
|
step_angle = 360 / leng;
|
||||||
for(i = [0:leng - 1]) {
|
for(i = [0:leng - 1]) {
|
||||||
translate(points[i])
|
translate(points[i])
|
||||||
rotate([90, 0, 90 + i * step_angle])
|
rotate([90, 0, 90 + i * step_angle])
|
||||||
linear_extrude(1, center = true)
|
linear_extrude(1, center = true)
|
||||||
text("A", valign = "center", halign = "center");
|
text("A", valign = "center", halign = "center");
|
||||||
}
|
}
|
||||||
|
|
||||||

|

|
@@ -36,7 +36,8 @@ Returns shape points of two splitting liquid shapes, kind of how cells divide. T
|
|||||||
shape_pts = shape_liquid_splitting(radius, centre_dist);
|
shape_pts = shape_liquid_splitting(radius, centre_dist);
|
||||||
width = centre_dist / 2 + radius;
|
width = centre_dist / 2 + radius;
|
||||||
|
|
||||||
rotate_extrude() difference() {
|
rotate_extrude()
|
||||||
|
difference() {
|
||||||
polygon(shape_pts);
|
polygon(shape_pts);
|
||||||
|
|
||||||
translate([-width, -radius])
|
translate([-width, -radius])
|
||||||
@@ -57,11 +58,11 @@ Returns shape points of two splitting liquid shapes, kind of how cells divide. T
|
|||||||
width = centre_dist + radius * 2;
|
width = centre_dist + radius * 2;
|
||||||
|
|
||||||
rotate_extrude()
|
rotate_extrude()
|
||||||
intersection() {
|
intersection() {
|
||||||
rotate(-90) polygon(shape_pts);
|
rotate(-90) polygon(shape_pts);
|
||||||
|
|
||||||
translate([radius / 2, 0])
|
translate([radius / 2, 0])
|
||||||
square([radius, width], center = true);
|
square([radius, width], center = true);
|
||||||
}
|
}
|
||||||
|
|
||||||

|

|
@@ -14,21 +14,30 @@ Returns shape points of a [Superformula](https://en.wikipedia.org/wiki/Superform
|
|||||||
phi_step = 0.05;
|
phi_step = 0.05;
|
||||||
|
|
||||||
polygon(shape_superformula(phi_step, 3, 3, 4.5, 10, 10));
|
polygon(shape_superformula(phi_step, 3, 3, 4.5, 10, 10));
|
||||||
|
|
||||||
translate([3, 0])
|
translate([3, 0])
|
||||||
polygon(shape_superformula(phi_step, 4, 4, 12, 15, 15));
|
polygon(shape_superformula(phi_step, 4, 4, 12, 15, 15));
|
||||||
|
|
||||||
translate([6, 0])
|
translate([6, 0])
|
||||||
polygon(shape_superformula(phi_step, 7, 7, 10, 6, 6));
|
polygon(shape_superformula(phi_step, 7, 7, 10, 6, 6));
|
||||||
|
|
||||||
translate([9, 0])
|
translate([9, 0])
|
||||||
polygon(shape_superformula(phi_step, 5, 5, 4, 4, 4));
|
polygon(shape_superformula(phi_step, 5, 5, 4, 4, 4));
|
||||||
|
|
||||||
translate([0, -4])
|
translate([0, -4])
|
||||||
scale(0.8) polygon(shape_superformula(phi_step, 5, 5, 2, 7, 7));
|
scale(0.8)
|
||||||
|
polygon(shape_superformula(phi_step, 5, 5, 2, 7, 7));
|
||||||
|
|
||||||
translate([3, -4])
|
translate([3, -4])
|
||||||
scale(0.25) polygon(shape_superformula(phi_step, 5, 5, 2, 13, 13));
|
scale(0.25)
|
||||||
|
polygon(shape_superformula(phi_step, 5, 5, 2, 13, 13));
|
||||||
|
|
||||||
translate([6, -4])
|
translate([6, -4])
|
||||||
polygon(shape_superformula(phi_step, 4, 4, 1, 1, 1));
|
polygon(shape_superformula(phi_step, 4, 4, 1, 1, 1));
|
||||||
|
|
||||||
translate([9, -4])
|
translate([9, -4])
|
||||||
scale(0.3) polygon(shape_superformula(phi_step, 4, 4, 1, 7, 8));
|
scale(0.3)
|
||||||
|
polygon(shape_superformula(phi_step, 4, 4, 1, 7, 8));
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
@@ -47,8 +47,8 @@ Creates all points and angles on the path of a spiral around a sphere. It return
|
|||||||
|
|
||||||
for(pa = points_angles) {
|
for(pa = points_angles) {
|
||||||
translate(pa[0]) rotate(pa[1])
|
translate(pa[0]) rotate(pa[1])
|
||||||
rotate([90, 0, 90]) linear_extrude(1)
|
rotate([90, 0, 90]) linear_extrude(1)
|
||||||
text("A", valign = "center", halign = "center");
|
text("A", valign = "center", halign = "center");
|
||||||
}
|
}
|
||||||
|
|
||||||
%sphere(40);
|
%sphere(40);
|
||||||
|
@@ -19,13 +19,15 @@ The 2D polygon should center at the origin and you have to determine the side le
|
|||||||
stereographic_extrude(shadow_side_leng = dimension, convexity = 10)
|
stereographic_extrude(shadow_side_leng = dimension, convexity = 10)
|
||||||
text(
|
text(
|
||||||
"M", size = dimension,
|
"M", size = dimension,
|
||||||
valign = "center", halign = "center"
|
valign = "center",
|
||||||
|
halign = "center"
|
||||||
);
|
);
|
||||||
|
|
||||||
color("black")
|
color("black")
|
||||||
text(
|
text(
|
||||||
"M", size = dimension,
|
"M", size = dimension,
|
||||||
valign = "center", halign = "center"
|
valign = "center",
|
||||||
|
halign = "center"
|
||||||
);
|
);
|
||||||
|
|
||||||

|

|
||||||
|
@@ -53,11 +53,11 @@ The indexes of the above triangles is:
|
|||||||
// spin section1
|
// spin section1
|
||||||
sections = [
|
sections = [
|
||||||
for(i = [0:55])
|
for(i = [0:55])
|
||||||
[
|
[
|
||||||
for(p = section1)
|
for(p = section1)
|
||||||
let(pt = ptf_rotate(p, [90, 0, 10 * i]))
|
let(pt = ptf_rotate(p, [90, 0, 10 * i]))
|
||||||
[pt.x, pt.y , pt.z + i]
|
[pt.x, pt.y , pt.z + i]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
sweep(sections);
|
sweep(sections);
|
||||||
@@ -83,11 +83,11 @@ The indexes of the above triangles is:
|
|||||||
// spin section1
|
// spin section1
|
||||||
sections = [
|
sections = [
|
||||||
for(i = [0:55])
|
for(i = [0:55])
|
||||||
[
|
[
|
||||||
for(p = section1)
|
for(p = section1)
|
||||||
let(pt = ptf_rotate(p, [90, 0, 10 * i]))
|
let(pt = ptf_rotate(p, [90, 0, 10 * i]))
|
||||||
[pt.x, pt.y , pt.z + i]
|
[pt.x, pt.y , pt.z + i]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
sweep(sections, "HOLLOW");
|
sweep(sections, "HOLLOW");
|
||||||
@@ -111,11 +111,11 @@ The indexes of the above triangles is:
|
|||||||
// spin section1
|
// spin section1
|
||||||
sections = [
|
sections = [
|
||||||
for(i = [0:55])
|
for(i = [0:55])
|
||||||
[
|
[
|
||||||
for(p = section1)
|
for(p = section1)
|
||||||
let(pt = ptf_rotate(p, [90, 0, 10 * i]))
|
let(pt = ptf_rotate(p, [90, 0, 10 * i]))
|
||||||
[pt.x, pt.y , pt.z + i]
|
[pt.x, pt.y , pt.z + i]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
sweep(
|
sweep(
|
||||||
|
@@ -54,9 +54,7 @@ Create a 3D version of [Voronoi diagram](https://en.wikipedia.org/wiki/Voronoi_d
|
|||||||
r * sin(yas[i])
|
r * sin(yas[i])
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
thickness = 2;
|
|
||||||
|
|
||||||
difference() {
|
difference() {
|
||||||
sphere(r);
|
sphere(r);
|
||||||
|
|
||||||
|
@@ -24,8 +24,8 @@ Draws a voxel-by-voxel curve from control points. The curve is drawn only from t
|
|||||||
];
|
];
|
||||||
|
|
||||||
for(pt = vx_curve(pts)) {
|
for(pt = vx_curve(pts)) {
|
||||||
translate(pt)
|
translate(pt)
|
||||||
cube(1);
|
cube(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#for(pt = pts) {
|
#for(pt = pts) {
|
||||||
|
@@ -26,11 +26,13 @@ Given a list of 0s and 1s that represent a black-and-white image. This function
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
for(pt = pts) {
|
for(pt = pts) {
|
||||||
translate(pt) square(1);
|
translate(pt)
|
||||||
|
square(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
translate([8, 0]) for(pt = pts) {
|
translate([8, 0]) for(pt = pts) {
|
||||||
translate(pt) text("A", font="Arial Black", 1);
|
translate(pt)
|
||||||
|
text("A", font="Arial Black", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||

|

|
||||||
|
Reference in New Issue
Block a user