From 4473ffa5dfa5d2afb02bf9a9095085cab2b03b08 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Sat, 6 Sep 2025 08:04:41 +0100 Subject: [PATCH] Forgot the 'skew' library! --- model/fourbar.scad | 2 +- model/library/skew.scad | 43 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 model/library/skew.scad diff --git a/model/fourbar.scad b/model/fourbar.scad index f94f0bc..7ab7953 100644 --- a/model/fourbar.scad +++ b/model/fourbar.scad @@ -3,7 +3,7 @@ // (c) Simon Brooke 2025; CC-BY-SA -include +include include include diff --git a/model/library/skew.scad b/model/library/skew.scad new file mode 100644 index 0000000..ec76370 --- /dev/null +++ b/model/library/skew.scad @@ -0,0 +1,43 @@ +/* Taken from https://gist.github.com/boredzo/fde487c724a40a26fa9c?permalink_comment_id=4258747 */ + +/* skew takes an array of six angles: + * x along y + * x along z + * y along x + * y along z + * z along x + * z along y + */ +module skew(dims) { +matrix = [ + [ 1, dims[0]/45, dims[1]/45, 0 ], + [ dims[2]/45, 1, dims[4]/45, 0 ], + [ dims[5]/45, dims[3]/45, 1, 0 ], + [ 0, 0, 0, 1 ] +]; +multmatrix(matrix) +children(); +} + +/* example: + * skew([45, 0, 0, 0, 0, 0]) + * cube([10,10,10]); + */ + +// Skews the child geometry. +// xy: Angle towards X along Y axis. +// xz: Angle towards X along Z axis. +// yx: Angle towards Y along X axis. +// yz: Angle towards Y along Z axis. +// zx: Angle towards Z along X axis. +// zy: Angle towards Z along Y axis. +module skew2(xy = 0, xz = 0, yx = 0, yz = 0, zx = 0, zy = 0) { + matrix = [ + [ 1, tan(xy), tan(xz), 0 ], + [ tan(yx), 1, tan(yz), 0 ], + [ tan(zx), tan(zy), 1, 0 ], + [ 0, 0, 0, 1 ] + ]; + multmatrix(matrix) + children(); +}