mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-08-01 17:30:27 +02:00
Enable using apply() on VNF and bezier patches.
This commit is contained in:
28
affine.scad
28
affine.scad
@@ -429,18 +429,22 @@ function affine3d_chain(affines, _m=undef, _i=0) =
|
|||||||
// transformed = apply(rot(45), circle(r=3)); // Rotates 2d circle data by 45 deg
|
// transformed = apply(rot(45), circle(r=3)); // Rotates 2d circle data by 45 deg
|
||||||
// transformed = apply(rot(45)*right(4)*scale(3), circle(r=3)); // Scales, translates and rotates 2d circle data
|
// transformed = apply(rot(45)*right(4)*scale(3), circle(r=3)); // Scales, translates and rotates 2d circle data
|
||||||
function apply(transform,points) =
|
function apply(transform,points) =
|
||||||
points==[] ? [] :
|
points==[] ? [] :
|
||||||
is_vector(points) ? apply(transform, [points])[0] :
|
is_vector(points) ? apply(transform, [points])[0] :
|
||||||
let(
|
is_list(points) && len(points)==2 && is_path(points[0],3) && is_list(points[1]) && is_vector(points[1][0])
|
||||||
tdim = len(transform[0])-1,
|
? [apply(transform, points[0]), points[1]] :
|
||||||
datadim = len(points[0])
|
is_list(points) && is_list(points[0]) && is_vector(points[0][0])
|
||||||
)
|
? [for (x=points) apply(transform,x)] :
|
||||||
tdim == 3 && datadim == 3 ? [for(p=points) point3d(transform*concat(p,[1]))] :
|
let(
|
||||||
tdim == 2 && datadim == 2 ? [for(p=points) point2d(transform*concat(p,[1]))] :
|
tdim = len(transform[0])-1,
|
||||||
tdim == 3 && datadim == 2 ?
|
datadim = len(points[0])
|
||||||
assert(is_2d_transform(transform),str("Transforms is 3d but points are 2d"))
|
)
|
||||||
[for(p=points) point2d(transform*concat(p,[0,1]))] :
|
tdim == 3 && datadim == 3 ? [for(p=points) point3d(transform*concat(p,[1]))] :
|
||||||
assert(false,str("Unsupported combination: transform with dimension ",tdim,", data of dimension ",datadim));
|
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"))
|
||||||
|
[for(p=points) point2d(transform*concat(p,[0,1]))] :
|
||||||
|
assert(false, str("Unsupported combination: transform with dimension ",tdim,", data of dimension ",datadim));
|
||||||
|
|
||||||
|
|
||||||
// Function: apply_list()
|
// Function: apply_list()
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
BOSL_VERSION = [2,0,528];
|
BOSL_VERSION = [2,0,529];
|
||||||
|
|
||||||
|
|
||||||
// Section: BOSL Library Version Functions
|
// Section: BOSL Library Version Functions
|
||||||
|
Reference in New Issue
Block a user