From 23660ec688d98d197047e6ee95d10cdbf845c5c3 Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Tue, 3 Dec 2019 19:04:56 -0800 Subject: [PATCH] Added missing affine mirror matrices. --- affine.scad | 33 +++++++++++++++++++++++++++++++++ version.scad | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/affine.scad b/affine.scad index fe695b2..e6a8a17 100644 --- a/affine.scad +++ b/affine.scad @@ -75,6 +75,22 @@ function affine2d_zrot(ang) = [ ]; +// Function: affine2d_mirror() +// Usage: +// mat = affine2d_mirror(v); +// Description: +// Returns the 3x3 affine2d matrix to perform a reflection of a 2D vector across the line given by its normal vector. +// Arguments: +// v = The normal vector of the line to reflect across. +function affine2d_mirror(v) = + let(v=normalize(point2d(v)), a=v.x, b=v.y) + [ + [1-2*a*a, 0-2*a*b, 0], + [0-2*a*b, 1-2*b*b, 0], + [ 0, 0, 1] + ]; + + // Function: affine2d_skew() // Usage: // affine2d_skew(xa, ya) @@ -243,6 +259,23 @@ function affine3d_rot_from_to(from, to) = let( ]; +// Function: affine3d_mirror() +// Usage: +// mat = affine3d_mirror(v); +// Description: +// Returns the 4x4 affine3d matrix to perform a reflection of a 3D vector across the plane given by its normal vector. +// Arguments: +// v = The normal vector of the plane to reflect across. +function affine3d_mirror(v) = + let(v=normalize(point3d(v)), a=v.x, b=v.y, c=v.z) + [ + [1-2*a*a, -2*a*b, -2*a*c, 0], + [ -2*b*a, 1-2*b*b, -2*b*c, 0], + [ -2*c*a, -2*c*b, 1-2*c*c, 0], + [ 0, 0, 0, 1] + ]; + + // Function: affine3d_skew_xy() // Usage: // affine3d_skew_xy(xa, ya) diff --git a/version.scad b/version.scad index f0dc571..ccc7a31 100644 --- a/version.scad +++ b/version.scad @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,49]; +BOSL_VERSION = [2,0,50]; // Section: BOSL Library Version Functions