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);
|
||||||
|
|
||||||

|

|
@@ -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);
|
||||||
}
|
}
|
||||||
|
@@ -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]));
|
@@ -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,14 +68,12 @@ 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,8 +42,7 @@ 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];
|
||||||
@@ -67,7 +66,6 @@ The value of `type` is the wall type of the cell. It can be `0`, `1`, `2` or `3`
|
|||||||
circle(wall_thickness / 2);
|
circle(wall_thickness / 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// outmost walls
|
// outmost walls
|
||||||
thetaStep = 360 / len(maze[rows - 1]);
|
thetaStep = 360 / len(maze[rows - 1]);
|
||||||
|
@@ -23,8 +23,7 @@ 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");
|
||||||
@@ -48,7 +47,6 @@ It's a helper for getting data from a theta-maze cell.
|
|||||||
circle(wall_thickness / 2);
|
circle(wall_thickness / 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
thetaStep = 360 / len(maze[rows - 1]);
|
thetaStep = 360 / len(maze[rows - 1]);
|
||||||
r = cell_width * (rows + 1);
|
r = cell_width * (rows + 1);
|
||||||
|
@@ -26,8 +26,7 @@ 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])]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@@ -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])
|
|
||||||
for(x = [0:.2:5])
|
|
||||||
[x, y, z, nz_perlin3(x, y, z, seed)]
|
[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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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,8 +27,7 @@ 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]
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -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,8 +25,7 @@ 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]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@@ -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,7 +255,8 @@ 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])
|
||||||
|
path_extrude(
|
||||||
shape_pentagram_pts,
|
shape_pentagram_pts,
|
||||||
[each pts, pts[0]],
|
[each pts, pts[0]],
|
||||||
closed = true,
|
closed = true,
|
||||||
@@ -272,7 +273,8 @@ 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])
|
||||||
|
path_extrude(
|
||||||
shape_pentagram_pts,
|
shape_pentagram_pts,
|
||||||
[each pts, pts[0]],
|
[each pts, pts[0]],
|
||||||
closed = true,
|
closed = true,
|
||||||
|
@@ -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,8 +17,7 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||

|

|
||||||
|
@@ -29,18 +29,17 @@ 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 = round(r * cos(a) * 100) / 100,
|
x = r * cos(a),
|
||||||
y = round(r * sin(a) * 100) / 100
|
y = r * sin(a)
|
||||||
)
|
)
|
||||||
[x, y]
|
[x, y]
|
||||||
];
|
];
|
||||||
@@ -49,7 +48,6 @@ It solidifies two surfaces with triangular mesh.
|
|||||||
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;
|
||||||
|
@@ -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])
|
||||||
|
@@ -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));
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
@@ -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"
|
||||||
);
|
);
|
||||||
|
|
||||||

|

|
||||||
|
@@ -55,8 +55,6 @@ Create a 3D version of [Voronoi diagram](https://en.wikipedia.org/wiki/Voronoi_d
|
|||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
thickness = 2;
|
|
||||||
|
|
||||||
difference() {
|
difference() {
|
||||||
sphere(r);
|
sphere(r);
|
||||||
|
|
||||||
|
@@ -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