Enable using apply() on VNF and bezier patches.

This commit is contained in:
Garth Minette 2021-01-19 04:32:40 -08:00
parent 291353d928
commit 8d753b471b
2 changed files with 25 additions and 21 deletions

View file

@ -431,6 +431,10 @@ function affine3d_chain(affines, _m=undef, _i=0) =
function apply(transform,points) =
points==[] ? [] :
is_vector(points) ? apply(transform, [points])[0] :
is_list(points) && len(points)==2 && is_path(points[0],3) && is_list(points[1]) && is_vector(points[1][0])
? [apply(transform, points[0]), points[1]] :
is_list(points) && is_list(points[0]) && is_vector(points[0][0])
? [for (x=points) apply(transform,x)] :
let(
tdim = len(transform[0])-1,
datadim = len(points[0])
@ -438,9 +442,9 @@ function apply(transform,points) =
tdim == 3 && datadim == 3 ? [for(p=points) point3d(transform*concat(p,[1]))] :
tdim == 2 && datadim == 2 ? [for(p=points) point2d(transform*concat(p,[1]))] :
tdim == 3 && datadim == 2 ?
assert(is_2d_transform(transform),str("Transforms is 3d but points are 2d"))
assert(is_2d_transform(transform), str("Transforms is 3d but points are 2d"))
[for(p=points) point2d(transform*concat(p,[0,1]))] :
assert(false,str("Unsupported combination: transform with dimension ",tdim,", data of dimension ",datadim));
assert(false, str("Unsupported combination: transform with dimension ",tdim,", data of dimension ",datadim));
// Function: apply_list()

View file

@ -6,7 +6,7 @@
//////////////////////////////////////////////////////////////////////
BOSL_VERSION = [2,0,528];
BOSL_VERSION = [2,0,529];
// Section: BOSL Library Version Functions