diff --git a/affine.scad b/affine.scad index e6a8a17..ca741ba 100644 --- a/affine.scad +++ b/affine.scad @@ -276,11 +276,31 @@ function affine3d_mirror(v) = ]; +// Function: affine3d_skew() +// Usage: +// mat = affine3d_skew([sxy], [sxz], [syx], [xyz], [szx], [szy]); +// Description: +// Returns the 4x4 affine3d matrix to perform a skew transformation. +// Arguments: +// sxy = Skew factor multiplier for skewing along the X axis as you get farther from the Y axis. Default: 0 +// sxz = Skew factor multiplier for skewing along the X axis as you get farther from the Z axis. Default: 0 +// syx = Skew factor multiplier for skewing along the Y axis as you get farther from the X axis. Default: 0 +// syz = Skew factor multiplier for skewing along the Y axis as you get farther from the Z axis. Default: 0 +// szx = Skew factor multiplier for skewing along the Z axis as you get farther from the X axis. Default: 0 +// szy = Skew factor multiplier for skewing along the Z axis as you get farther from the Y axis. Default: 0 +function affine3d_skew(sxy=0, sxz=0, syx=0, xyz=0, szx=0, szy=0) = [ + [ 1, sxy, sxz, 0], + [syx, 1, syz, 0], + [szx, szy, 1, 0], + [ 0, 0, 0, 1] +]; + + // Function: affine3d_skew_xy() // Usage: // affine3d_skew_xy(xa, ya) // Description: -// Returns the 4x4 affine3d matrix to perform a skew transformation along the XY plane.. +// Returns the 4x4 affine3d matrix to perform a skew transformation along the XY plane. // Arguments: // xa = Skew angle, in degrees, in the direction of the X axis. // ya = Skew angle, in degrees, in the direction of the Y axis. diff --git a/transforms.scad b/transforms.scad index b51c1ee..98c1a8c 100644 --- a/transforms.scad +++ b/transforms.scad @@ -952,12 +952,9 @@ function zflip(z=0,p) = // trace_polyline(close_path(pts), showpts=true); module skew(sxy=0, sxz=0, syx=0, syz=0, szx=0, szy=0) { - multmatrix([ - [ 1, sxy, sxz, 0], - [syx, 1, syz, 0], - [szx, szy, 1, 0], - [ 0, 0, 0, 1] - ]) children(); + multmatrix( + affine3d_skew(sxy=sxy, sxz=sxz, syx=syx, syz=syz, szx=szx, szy=szy) + ) children(); } function skew(p, sxy=0, sxz=0, syx=0, syz=0, szx=0, szy=0, planar=false) = @@ -967,12 +964,7 @@ function skew(p, sxy=0, sxz=0, syx=0, syz=0, szx=0, szy=0, planar=false) = [ 1, sxy, 0], [syx, 1, 0], [ 0, 0, 1] - ] : [ - [ 1, sxy, sxz, 0], - [syx, 1, syz, 0], - [szx, szy, 1, 0], - [ 0, 0, 0, 1] - ] + ] : affine3d_skew(sxy=sxy, sxz=sxz, syx=syx, syz=syz, szx=szx, szy=szy) ) is_undef(p)? m : assert(is_list(p)) diff --git a/version.scad b/version.scad index 70e7690..13988ab 100644 --- a/version.scad +++ b/version.scad @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,61]; +BOSL_VERSION = [2,0,62]; // Section: BOSL Library Version Functions diff --git a/walls.scad b/walls.scad index 813ac7b..76ab063 100644 --- a/walls.scad +++ b/walls.scad @@ -352,8 +352,8 @@ module sparse_strut(h=50, l=100, thick=4, maxang=30, strut=5, max_bridge=20, anc } yspread(ystep, n=yreps) { xspread(zstep, n=zreps) { - skew_xy(planar=true, ya=-ang) square([(h-strut)/zreps, strut], center=true); - skew_xy(planar=true, ya= ang) square([(h-strut)/zreps, strut], center=true); + skew(syx=tan(-ang)) square([(h-strut)/zreps, strut], center=true); + skew(syx=tan( ang)) square([(h-strut)/zreps, strut], center=true); } } } @@ -440,7 +440,7 @@ module sparse_strut3d(h=50, l=100, w=50, thick=3, maxang=40, strut=3, max_bridge for (soff = [0:1:supp_reps-1] ) { yflip_copy() { back(soff*supp_step) { - skew_xy(ya=supp_ang) { + skew(syz=tan(supp_ang)) { cube([strut, strut, zstep], anchor=BOTTOM); } }