doc fixes

This commit is contained in:
Adrian Mariano
2025-04-24 06:49:22 -04:00
parent a635ff6806
commit 730f188602
3 changed files with 58 additions and 68 deletions

View File

@@ -3621,23 +3621,17 @@ function _showstats_isosurface(voxsize, bbox, isoval, cubes, triangles, faces) =
// color("blue") down(1)
// square((len(field)-1)*pixsize, true);
// Example(3D,NoAxes): You can pass a function literal taking x,y arguments, in which case the center value of each pixel is computed in addition to the corners for somewhat greater resolution than the specified pixel size. By default, two smoothing passes are performed on the output paths when making contours from a function.
// function wave2d(x,y,wavelen) =
// 40*cos(180/wavelen*norm([x,y]));
//
// isoval=-30;
// pixsize = 10;
// wavelen=42;
// translate([0,0,isoval]) color("green") zrot(-90)
// contour(function(x,y) wave2d(x,y,wavelen),
// bounding_box=[[-50,-50],[50,50]],
// isovalue=[isoval,INF], pixel_size=pixsize);
//
// %heightfield(size=[100,100], bottom=-45, data=[
// for (y=[-50:pixsize:50]) [
// for(x=[-50:pixsize:50])
// wave2d(x,y,wavelen)
// ]
// ], style="quincunx");
wavelen=42;
wave2d = function(x,y)
40*cos(180/wavelen*norm([x,y]));
isoval=-30;
pixsize = 10;
translate([0,0,isoval]) color("green") zrot(-90)
contour(wave2d,
bounding_box=[[-50,-50],[50,50]],
isovalue=[isoval,INF], pixel_size=pixsize);
%plot3d(wave2d, [-50:pixsize:50],[-50:pixsize:50],
style="quincunx",base=5);
// Example(2D,NoAxes): Here's a simple function that produces a contour in the shape of a flower with some petals. Note that the function has smaller values inside the shape so we choose a `-INF` bound for the isovalue.
// f = function (x, y, petals=5)
// sin(petals*atan2(y,x)) + norm([x,y]);
@@ -3665,13 +3659,8 @@ function _showstats_isosurface(voxsize, bbox, isoval, cubes, triangles, faces) =
// bbox = 720;
// up(isovalue) color("red") linear_extrude(1)
// contour(f, [isovalue,INF], bbox, pixel_size);
// %heightfield(size=[720,720], data = [
// for (y=[-360:pixel_size/2:360]) [
// for(x=[-360:pixel_size/2:360])
// f(x,y)
// ]
// ],
// bottom=-70, maxz=70, style="quincunx");
// %plot3d(f, [-360:pixel_size/2:360],
// [-360:pixel_size/2:360], style="quincunx");
// Example(2D,NoAxes): A [Cassini oval](https://en.wikipedia.org/wiki/Cassini_oval) is a curve drawn such that for any point on the perimeter, the product of the distances from two fixed points is constant. The curve resembles two circular [metaballs](#functionmodule-metaballs2d) interacting. When the ratio `b/a=1`, there is a cusp where two contours meet at the origin, although the contour algorithm doesn't allow the two contours to touch.
// a=4; b=4.1;
// f = function(x,y) (x^2+y^2)^2 - 2*a^2*(x^2-y^2) + a^4;

View File

@@ -1245,6 +1245,7 @@ function regular_prism(n,
// Example(3D,NoAxes,VPT=[-0.212176,-0.651766,0.124004],VPR=[58.5,0,21.5],VPD=29.2405): This texture has an asymmetry even with the default `tex_extra=1`.
// textured_tile("trunc_ribs", 10, tex_reps=[5,1]);
// Example(3D,NoAxes,VPT=[-0.212176,-0.651766,0.124004],VPR=[58.5,0,21.5],VPD=29.2405): It could be fixed by setting `tex_extra=2`, which would place an extra flat strip on the right. But another option is to use the `tex_skip` parameter to trim the flat part from the left. Note that we are also skipping in the y direction, but it doesn't make a difference for this texture, except that you need to have enough texture tiles to accommodate the skip, so we increased the Y reps value to 2. You can also set `tex_skip` to a vector.
// textured_tile("trunc_ribs", 10, tex_reps=[5,2], tex_skip=1);
// Example(3D,NoAxes): Textures can be used to place images onto objects. Here we place a very simple image into a cube, leaving a border around the image.
// textured_tile("trunc_ribs", 10, tex_reps=[5,2], tex_skip=1);
// img = [
@@ -2181,7 +2182,7 @@ function cylinder(h, r1, r2, center, r, d, d1, d2, anchor, spin=0, orient=UP) =
// texture="trunc_ribs", tex_taper=10,
// tex_size=[5,1]);
//
// Example: Making a Clay Pattern Roller
// Example(3D,Med,NoAxes): Making a Clay Pattern Roller
// tex = [
// [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,],
// [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,],
@@ -4403,13 +4404,13 @@ function plot3d(f,x,y,zclip, zspan, base=1, anchor="origin", orient=UP, spin=0,
// "intersect" = Anchors to the surface of the shape.
// Named Anchors:
// "origin" = Anchor at the origin, oriented UP.
// Example(3D,NoScale):
// Example(3D,NoScale,VPR=[85.10,0.00,127.90],VPD=292.71,VPT=[21.15,13.27,0.90):
// f = function (x,y) 5*cos(5*norm([x*180/50,y*180/50]))+5;
// plot_revolution(f, arclength=[-50:1:50], z=[-50:1:50], r=30);
// Example(3D,NoScale): When specifying angle, the pattern shrinks at the top of the cone.
// Example(3D,NoScale,VPR=[69.00,0.00,96.40],VPD=361.36,VPT=[14.10,5.03,4.53]): When specifying angle, the pattern shrinks at the top of the cone.
// g = function (x,y) 5*sin(4*x)*cos(6*y)+5;
// plot_revolution(g, z=[-60:2:60], angle=[-180:4:180], r1=30, r2=16);
// Example(3D,NoScale): When specifying arc length, the shape wraps around more cone at the top
// Example(3D,NoScale,VPR=[69.00,0.00,96.40],VPD=361.36,VPT=[14.10,5.03,4.53]): When specifying arc length, the shape wraps around more cone at the top
// g = function (x,y) 5*sin(8*x)*cos(6*y)+5;
// plot_revolution(g, z=[-60:.5:60], arclength=[-45:.5:45],r1=30,r2=16);
// Example(3D,VPR=[60.60,0.00,100.60],VPD=100.87,VPT=[-1.84,-1.70,5.63]): Here we place a simple ridge function onto a cone using angle. Note how the ribs narrow with the radius.

View File

@@ -211,43 +211,7 @@ EMPTY_VNF = [[],[]]; // The standard empty VNF with no vertices or faces.
// apply(m, [ [rgroove[0].x,0,-z], each rgroove, [last(rgroove).x,0,-z] ])
// ], caps=true, col_wrap=true, reverse=true);
// vnf_polyhedron(vnf, convexity=8);
// Example(3D,Med,NoAxes,VPD=300,VPT=[48,48,0]): When applying a texture to a vertex array, remember that the density of the texture follows the density of the vertex array grid. Here is a surface with a wrinkle in both x and y directions, using location data generated by {{smooth_path()}}. The bezier curves have non-uniformly distributed spline points, indicated by the red dots along each edge. This results in a non-uniform distribution of the texture tiling.
// include <BOSL2/rounding.scad>
//
// xprofile = smooth_path([[0,0,0], [25,0,0], [49,0,-10], [51,0,10], [75,0,0], [100,0,0]],
// relsize=1, method="corners", splinesteps=4);
// yprofile = smooth_path([[0,0,0], [0,25,0], [0,49,-10], [0,51,10], [0,75,0], [0,100,0]],
// relsize=1, method="corners", splinesteps=4);
// polystack = [
// for(xp=xprofile) [
// for(yp=yprofile) [xp.x, yp.y, xp.z+yp.z]
// ]
// ];
// vnf_vertex_array(polystack, texture="checkers", tex_depth=2, tex_reps=[8,8]);
// color("red") {
// for(p=xprofile) translate(p-[0,4,0]) sphere(1.5);
// for(p=yprofile) translate(p-[4,0,0]) sphere(1.5);
// }
// Example(3D,Med,NoAxes,VPD=300,VPT=[48,48,0]): By passing the spline curves into {{resample_path()}}, we can get a uniform distribution of the same number of x and y profile points, as shown by the red dots. This results in a uniform distribution of the texture tiling.
// include <BOSL2/rounding.scad>
//
// xprof = smooth_path([[0,0,0], [25,0,0], [49,0,-10], [51,0,10], [75,0,0], [100,0,0]],
// relsize=1, method="corners", splinesteps=4);
// yprof = smooth_path([[0,0,0], [0,25,0], [0,49,-10], [0,51,10], [0,75,0], [0,100,0]],
// relsize=1, method="corners", splinesteps=4);
// xprofile = resample_path(xprof, len(xprof), closed=false);
// yprofile = resample_path(yprof, len(yprof), closed=false);
// polystack = [
// for(xp=xprofile) [
// for(yp=yprofile) [xp.x, yp.y, xp.z+yp.z]
// ]
// ];
// vnf_vertex_array(polystack, texture="checkers", tex_depth=2, tex_reps=[8,8]);
// color("red") {
// for(p=xprofile) translate(p-[0,4,0]) sphere(1.5);
// for(p=yprofile) translate(p-[4,0,0]) sphere(1.5);
// }
// Example(3D,NoAxes,VPR=[73,0,27],VPD=260,VPT=[0,0,42]): This is a vase shape that cannot be constructed with rotational or linear sweeps. Using a vertex array to create a stack of polygons is the most practical way to make this and many other shapes. The cross-section is a rounded 9-pointed star that changes size and rotates back and forth as it rises in the z direction.
// Example(3D,NoAxes,VPR=[73,0,27],VPD=260,VPT=[0,0,42]): This vase shape cannot be constructed with rotational or linear sweeps. Using a vertex array to create a stack of polygons is the most practical way to make this and many other shapes. The cross-section is a rounded 9-pointed star that changes size and rotates back and forth as it rises in the z direction.
// include <BOSL2/rounding.scad>
//
// vprofile =
@@ -264,7 +228,7 @@ EMPTY_VNF = [[],[]]; // The standard empty VNF with no vertices or faces.
// z)
// ];
// vnf_polyhedron(vnf_vertex_array(polystack, col_wrap=true, caps=true));
// Example(3D,NoAxes,VPR=[73,0,27],VPD=260,VPT=[0,0,42]): The previous vase shape with a pebbly texture, simply by adding `texture="dots"` to the `vnf_vertex_array()` call. Because textures are spread over grid units and not measurement units, the data points in the polygon stack should be more or less uniformly spaced. Each star-shaped cross-section has uniformly-spaced points, but the vertical profile `vprofile` in the previous example isn't uniform because the control points aren't evenly spaced. We fix this by passing this profile into `resample_path()`, which results in a uniform texture density.
// Example(3D,NoAxes,VPR=[73,0,27],VPD=260,VPT=[0,0,42]): The previous vase shape with a pebbly texture, simply by adding `texture="dots"` to the `vnf_vertex_array()` call. Because textures are spread over grid units and not measurement units, the data points in the polygon stack should be uniformly spaced.
// include <BOSL2/rounding.scad>
//
// vprofile = resample_path(
@@ -283,19 +247,55 @@ EMPTY_VNF = [[],[]]; // The standard empty VNF with no vertices or faces.
// ];
// vnf_polyhedron(vnf_vertex_array(polystack, col_wrap=true, caps=true,
// texture="dots", tex_samples=1, tex_size=5));
// Example(3D,Med,NoAxes,VPR=[0,0,0],VPD=126.00,VPT=[-0.35,-0.54,4.09]): This point array defines a square region but with a non-uniform grid.
// Example(3D,Med,NoAxes,VPR=[0,0,0],VPD=126.00,VPT=[-0.35,-0.54,4.09]): This point array defines a simple square, but with a non-uniform grid.
// pts = [for(x=[-1:.1:1])
// [for(y=[-1:.1:1])
// zrot(45*min([abs(x-1),abs(x+1),abs(y-1),abs(y+1)]),
// 20*[x,y,0])]];
// vnf=vnf_vertex_array(pts);
// color("blue") vnf_wireframe(vnf,width=.2);
// Example(3D,Med,NoAxes,VPR=[0,0,0],VPD=126.00,VPT=[-0.35,-0.54,4.09]): The non-uniform grid gives rise to a non-uniform texturing.
// Example(3D,Med,NoAxes,VPR=[0,0,0],VPD=126.00,VPT=[-0.35,-0.54,4.09]): The non-uniform grid gives rise to a non-uniform texturing, showing the effect of the uniformity and distribution of the points when creating a texture.
// pts = [for(x=[-1:.1:1])
// [for(y=[-1:.1:1])
// zrot(45*min([abs(x-1),abs(x+1),abs(y-1),abs(y+1)]),
// 20*[x,y,0])]];
// vnf_vertex_array(pts,texture="dots",tex_reps=15);
// Example(3D,Med,NoAxes,VPD=300,VPT=[48,48,0]): Here is another example showing the effect of nonuniform sampling. Here is a surface with a wrinkle in both x and y directions, using location data generated by {{smooth_path()}}, which uses beziers. Bezier curves have non-uniformly distributed points, indicated by the red dots along each edge, which results in a non-uniform texture tiling.
// include <BOSL2/rounding.scad>
//
// xprofile = smooth_path([[0,0,0], [25,0,0], [49,0,-10], [51,0,10], [75,0,0], [100,0,0]],
// relsize=1, method="corners", splinesteps=4);
// yprofile = smooth_path([[0,0,0], [0,25,0], [0,49,-10], [0,51,10], [0,75,0], [0,100,0]],
// relsize=1, method="corners", splinesteps=4);
// polystack = [
// for(xp=xprofile) [
// for(yp=yprofile) [xp.x, yp.y, xp.z+yp.z]
// ]
// ];
// vnf_vertex_array(polystack, texture="checkers", tex_depth=2, tex_reps=[8,8]);
// color("red") {
// for(p=xprofile) translate(p-[0,4,0]) sphere(1.5);
// for(p=yprofile) translate(p-[4,0,0]) sphere(1.5);
// }
// Example(3D,Med,NoAxes,VPD=300,VPT=[48,48,0]): By passing the spline curves into {{resample_path()}}, we can get a uniform distribution of the x and y profile points, as shown by the red dots, which results in a uniform texture tiling.
// include <BOSL2/rounding.scad>
//
// xprof = smooth_path([[0,0,0], [25,0,0], [49,0,-10], [51,0,10], [75,0,0], [100,0,0]],
// relsize=1, method="corners", splinesteps=4);
// yprof = smooth_path([[0,0,0], [0,25,0], [0,49,-10], [0,51,10], [0,75,0], [0,100,0]],
// relsize=1, method="corners", splinesteps=4);
// xprofile = resample_path(xprof, len(xprof), closed=false);
// yprofile = resample_path(yprof, len(yprof), closed=false);
// polystack = [
// for(xp=xprofile) [
// for(yp=yprofile) [xp.x, yp.y, xp.z+yp.z]
// ]
// ];
// vnf_vertex_array(polystack, texture="checkers", tex_depth=2, tex_reps=[8,8]);
// color("red") {
// for(p=xprofile) translate(p-[0,4,0]) sphere(1.5);
// for(p=yprofile) translate(p-[4,0,0]) sphere(1.5);
// }
module vnf_vertex_array(