1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 22:28:16 +01:00
dotSCAD/docs/lib3x-contours.md

53 lines
1.3 KiB
Markdown
Raw Normal View History

2020-04-05 16:20:23 +08:00
# contours
Computes contour polygons by applying [marching squares](https://en.wikipedia.org/wiki/Marching_squares) to a rectangular list of numeric values.
**Since:** 2.3
## Parameters
2021-02-24 14:25:59 +08:00
- `points` : A list of points `[x, y, z]`. See examples below.
2020-04-05 16:20:23 +08:00
- `threshold` : When applying a threshold value, the function returns isolines. When applying upper and lower threshold values, it returns isobands.
## Examples
2022-06-06 13:11:46 +08:00
use <polyline_join.scad>
use <surface/sf_thicken.scad>
use <contours.scad>
2020-04-05 16:20:23 +08:00
min_value = 1;
max_value = 360;
resolution = 10;
function f(x, y) = sin(x) * cos(y) * 30;
points = [
for(y = [min_value:resolution:max_value])
2022-04-06 17:44:11 +08:00
[
for(x = [min_value:resolution:max_value])
[x, y, f(x, y)]
]
2020-04-05 16:20:23 +08:00
];
2021-07-03 11:53:58 +08:00
sf_thicken(points, 1);
2020-04-05 16:20:23 +08:00
translate([max_value, 0, 0])
for(z = [-30:5:30]) {
translate([0, 0, z])
linear_extrude(1)
for(isoline = contours(points, z)) {
2021-11-18 08:08:50 +08:00
polyline_join(isoline)
circle(.5);
2020-04-05 16:20:23 +08:00
}
}
translate([0, max_value])
for(z = [-30:5:30]) {
linear_extrude(35 + z)
for(isoband = contours(points, [z, z + 5])) {
polygon([for(p = isoband) [p[0], p[1]]]);
}
}
2021-02-24 21:09:54 +08:00
![contours](images/lib3x-contours-1.JPG)