mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-08-05 20:37:24 +02:00
Fixed data array heightfield handling.
This commit is contained in:
37
shapes.scad
37
shapes.scad
@@ -1711,12 +1711,12 @@ module arced_slot(
|
|||||||
// orient = Vector to rotate top towards. See [orient](attachments.scad#orient). Default: `UP`
|
// orient = Vector to rotate top towards. See [orient](attachments.scad#orient). Default: `UP`
|
||||||
// Example:
|
// Example:
|
||||||
// heightfield(size=[100,100], bottom=-20, data=[
|
// heightfield(size=[100,100], bottom=-20, data=[
|
||||||
// for (x=[-180:4:180]) [for(y=[-180:4:180]) 10*cos(3*norm([x,y]))]
|
// for (y=[-180:4:180]) [for(x=[-180:4:180]) 10*cos(3*norm([x,y]))]
|
||||||
// ]);
|
// ]);
|
||||||
// Example:
|
// Example:
|
||||||
// intersection() {
|
// intersection() {
|
||||||
// heightfield(size=[100,100], data=[
|
// heightfield(size=[100,100], data=[
|
||||||
// for (x=[-180:5:180]) [for(y=[-180:5:180]) 10+5*cos(3*x)*sin(3*y)]
|
// for (y=[-180:5:180]) [for(x=[-180:5:180]) 10+5*cos(3*x)*sin(3*y)]
|
||||||
// ]);
|
// ]);
|
||||||
// cylinder(h=50,d=100);
|
// cylinder(h=50,d=100);
|
||||||
// }
|
// }
|
||||||
@@ -1748,23 +1748,24 @@ function heightfield(data, size=[100,100], xrange=[-1:0.04:1], yrange=[-1:0.04:1
|
|||||||
? [for (i=idx(data)) i]
|
? [for (i=idx(data)) i]
|
||||||
: assert(is_list(yrange)||is_range(yrange)) [for (y=yrange) y],
|
: assert(is_list(yrange)||is_range(yrange)) [for (y=yrange) y],
|
||||||
xcnt = len(xvals),
|
xcnt = len(xvals),
|
||||||
ycnt = len(yvals),
|
|
||||||
minx = min(xvals),
|
minx = min(xvals),
|
||||||
maxx = max(xvals),
|
maxx = max(xvals),
|
||||||
|
ycnt = len(yvals),
|
||||||
miny = min(yvals),
|
miny = min(yvals),
|
||||||
maxy = max(yvals),
|
maxy = max(yvals),
|
||||||
verts = is_list(data) ? [
|
verts = is_list(data) ? [
|
||||||
for (y = [0:1:yvals-1]) [
|
for (y = [0:1:ycnt-1]) [
|
||||||
for (x = [0:1:xvals-1]) [
|
for (x = [0:1:xcnt-1]) [
|
||||||
size.x * (x/(xvals-1)-0.5),
|
size.x * (x/(xcnt-1)-0.5),
|
||||||
size.y * (y/(yvals-1)-0.5),
|
size.y * (y/(ycnt-1)-0.5),
|
||||||
data[y][x]
|
data[y][x]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
] : [
|
] : [
|
||||||
for (x = xrange) [
|
for (y = yrange) [
|
||||||
for (y = yrange)
|
for (x = xrange) let(
|
||||||
let( z = data(x,y) ) [
|
z = data(x,y)
|
||||||
|
) [
|
||||||
size.x * ((x-minx)/(maxx-minx)-0.5),
|
size.x * ((x-minx)/(maxx-minx)-0.5),
|
||||||
size.y * ((y-miny)/(maxy-miny)-0.5),
|
size.y * ((y-miny)/(maxy-miny)-0.5),
|
||||||
min(maxz, max(bottom+0.1, default(z,0)))
|
min(maxz, max(bottom+0.1, default(z,0)))
|
||||||
@@ -1772,30 +1773,30 @@ function heightfield(data, size=[100,100], xrange=[-1:0.04:1], yrange=[-1:0.04:1
|
|||||||
]
|
]
|
||||||
],
|
],
|
||||||
vnf = vnf_merge([
|
vnf = vnf_merge([
|
||||||
vnf_vertex_array(verts, style=style),
|
vnf_vertex_array(verts, style=style, reverse=true),
|
||||||
vnf_vertex_array([
|
vnf_vertex_array([
|
||||||
|
verts[0],
|
||||||
[for (v=verts[0]) [v.x, v.y, bottom]],
|
[for (v=verts[0]) [v.x, v.y, bottom]],
|
||||||
verts[0]
|
|
||||||
]),
|
]),
|
||||||
vnf_vertex_array([
|
vnf_vertex_array([
|
||||||
|
[for (v=verts[ycnt-1]) [v.x, v.y, bottom]],
|
||||||
verts[ycnt-1],
|
verts[ycnt-1],
|
||||||
[for (v=verts[ycnt-1]) [v.x, v.y, bottom]]
|
|
||||||
]),
|
]),
|
||||||
vnf_vertex_array([
|
vnf_vertex_array([
|
||||||
[for (r=verts) let(v=r[0]) v],
|
|
||||||
[for (r=verts) let(v=r[0]) [v.x, v.y, bottom]],
|
[for (r=verts) let(v=r[0]) [v.x, v.y, bottom]],
|
||||||
|
[for (r=verts) let(v=r[0]) v],
|
||||||
]),
|
]),
|
||||||
vnf_vertex_array([
|
vnf_vertex_array([
|
||||||
[for (r=verts) let(v=r[xcnt-1]) [v.x, v.y, bottom]],
|
|
||||||
[for (r=verts) let(v=r[xcnt-1]) v],
|
[for (r=verts) let(v=r[xcnt-1]) v],
|
||||||
|
[for (r=verts) let(v=r[xcnt-1]) [v.x, v.y, bottom]],
|
||||||
]),
|
]),
|
||||||
vnf_vertex_array([
|
vnf_vertex_array([
|
||||||
[
|
[
|
||||||
for (r=verts) let(v=r[0]) [v.x, v.y, bottom],
|
|
||||||
for (v=verts[ycnt-1]) [v.x, v.y, bottom],
|
|
||||||
], [
|
|
||||||
for (v=verts[0]) [v.x, v.y, bottom],
|
for (v=verts[0]) [v.x, v.y, bottom],
|
||||||
for (r=verts) let(v=r[xcnt-1]) [v.x, v.y, bottom],
|
for (r=verts) let(v=r[xcnt-1]) [v.x, v.y, bottom],
|
||||||
|
], [
|
||||||
|
for (r=verts) let(v=r[0]) [v.x, v.y, bottom],
|
||||||
|
for (v=verts[ycnt-1]) [v.x, v.y, bottom],
|
||||||
]
|
]
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
BOSL_VERSION = [2,0,502];
|
BOSL_VERSION = [2,0,503];
|
||||||
|
|
||||||
|
|
||||||
// Section: BOSL Library Version Functions
|
// Section: BOSL Library Version Functions
|
||||||
|
Reference in New Issue
Block a user