mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-21 05:52:16 +02:00
add doc
This commit is contained in:
@@ -82,7 +82,7 @@ See [examples](examples).
|
|||||||
- [bezier_smooth](https://openhome.cc/eGossip/OpenSCAD/lib2x-bezier_smooth.html)
|
- [bezier_smooth](https://openhome.cc/eGossip/OpenSCAD/lib2x-bezier_smooth.html)
|
||||||
- [midpt_smooth](https://openhome.cc/eGossip/OpenSCAD/lib2x-midpt_smooth.html)
|
- [midpt_smooth](https://openhome.cc/eGossip/OpenSCAD/lib2x-midpt_smooth.html)
|
||||||
- [in_polyline](https://openhome.cc/eGossip/OpenSCAD/lib2x-in_polyline.html)
|
- [in_polyline](https://openhome.cc/eGossip/OpenSCAD/lib2x-in_polyline.html)
|
||||||
- contours (2.3 Preview)
|
- [contours](https://openhome.cc/eGossip/OpenSCAD/lib2x-contours.html) (2.3 Preview)
|
||||||
|
|
||||||
### Path
|
### Path
|
||||||
- [arc_path](https://openhome.cc/eGossip/OpenSCAD/lib2x-arc_path.html)
|
- [arc_path](https://openhome.cc/eGossip/OpenSCAD/lib2x-arc_path.html)
|
||||||
|
BIN
docs/images/lib2x-contours-1.JPG
Normal file
BIN
docs/images/lib2x-contours-1.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 83 KiB |
51
docs/lib2x-contours.md
Normal file
51
docs/lib2x-contours.md
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
# 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
|
||||||
|
|
||||||
|
- `points` : 2 value array `[x, y]`, rectangle with dimensions `x` and `y`.
|
||||||
|
- `threshold` : When applying a threshold value, the function returns isolines. When applying upper and lower threshold values, it returns isobands.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
use <hull_polyline2d.scad>;
|
||||||
|
use <function_grapher.scad>;
|
||||||
|
use <contours.scad>;
|
||||||
|
|
||||||
|
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])
|
||||||
|
[
|
||||||
|
for(x = [min_value:resolution:max_value])
|
||||||
|
[x, y, f(x, y)]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
function_grapher(points, 1);
|
||||||
|
|
||||||
|
translate([max_value, 0, 0])
|
||||||
|
for(z = [-30:5:30]) {
|
||||||
|
translate([0, 0, z])
|
||||||
|
linear_extrude(1)
|
||||||
|
for(isoline = contours(points, z)) {
|
||||||
|
hull_polyline2d(isoline, width = 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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]]]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|

|
@@ -1,3 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* contours.scad
|
||||||
|
*
|
||||||
|
* @copyright Justin Lin, 2020
|
||||||
|
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||||
|
*
|
||||||
|
* @see https://openhome.cc/eGossip/OpenSCAD/lib2x-contours.html
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
|
||||||
use <_impl/_contours_impl.scad>;
|
use <_impl/_contours_impl.scad>;
|
||||||
|
|
||||||
function contours(points, threshold) =
|
function contours(points, threshold) =
|
||||||
|
Reference in New Issue
Block a user