From 035e1fa1b454793fbfecc10609b2b0eb8d4856dc Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Tue, 7 May 2019 17:35:32 +0800 Subject: [PATCH] use built-in matrix multi --- src/__private__/__m_multiply.scad | 13 ------------- src/along_with.scad | 7 +++---- src/m_cumulate.scad | 6 ++---- src/m_multiply.scad | 13 ------------- src/m_rotation.scad | 8 +------- src/m_shearing.scad | 1 - src/path_extrude.scad | 5 ++--- src/shear.scad | 1 - 8 files changed, 8 insertions(+), 46 deletions(-) delete mode 100644 src/__private__/__m_multiply.scad delete mode 100644 src/m_multiply.scad diff --git a/src/__private__/__m_multiply.scad b/src/__private__/__m_multiply.scad deleted file mode 100644 index 9b5d538c..00000000 --- a/src/__private__/__m_multiply.scad +++ /dev/null @@ -1,13 +0,0 @@ -function __m_multiply(ma, mb) = - let( - c1 = [mb[0][0], mb[1][0], mb[2][0], mb[3][0]], - c2 = [mb[0][1], mb[1][1], mb[2][1], mb[3][1]], - c3 = [mb[0][2], mb[1][2], mb[2][2], mb[3][2]], - c4 = [mb[0][3], mb[1][3], mb[2][3], mb[3][3]] - ) - [ - [ma[0] * c1, ma[0] * c2, ma[0] * c3, ma[0] * c4], - [ma[1] * c1, ma[1] * c2, ma[1] * c3, ma[1] * c4], - [ma[2] * c1, ma[2] * c2, ma[2] * c3, ma[2] * c4], - [ma[3] * c1, ma[3] * c2, ma[3] * c3, ma[3] * c4] - ]; \ No newline at end of file diff --git a/src/along_with.scad b/src/along_with.scad index 39cb1689..ffd0a832 100644 --- a/src/along_with.scad +++ b/src/along_with.scad @@ -7,11 +7,10 @@ * @see https://openhome.cc/eGossip/OpenSCAD/lib-along_with.html * **/ - + include <__private__/__angy_angz.scad>; include <__private__/__is_vector.scad>; include <__private__/__to3d.scad>; -include <__private__/__m_multiply.scad>; // Becuase of improving the performance, this module requires m_rotation.scad which doesn't require in dotSCAD 1.0. // For backward compatibility, I directly include m_rotation here. @@ -56,7 +55,7 @@ module along_with(points, angles, twist = 0, scale = 1.0) { i == leng_rot_matrice - 2 ? [ rot_matrice[leng_rot_matrice_minus_one], - __m_multiply(rot_matrice[leng_rot_matrice_minus_two], rot_matrice[leng_rot_matrice_minus_one]) + rot_matrice[leng_rot_matrice_minus_two] * rot_matrice[leng_rot_matrice_minus_one] ] : cumulated_rot_matrice_sub(i, rot_matrice); @@ -66,7 +65,7 @@ module along_with(points, angles, twist = 0, scale = 1.0) { curr_matrix = rot_matrice[i], prev_matrix = matrice[len(matrice) - 1] ) - concat(matrice, [__m_multiply(curr_matrix, prev_matrix)]); + concat(matrice, [curr_matrix * prev_matrix]); // align modules diff --git a/src/m_cumulate.scad b/src/m_cumulate.scad index e9893b33..ae511501 100644 --- a/src/m_cumulate.scad +++ b/src/m_cumulate.scad @@ -8,12 +8,10 @@ * **/ -include <__private__/__m_multiply.scad>; - function _m_cumulate(matrice, i) = i == len(matrice) - 2 ? - __m_multiply(matrice[i], matrice[i + 1]) : - __m_multiply(matrice[i], _m_cumulate(matrice, i + 1)); + matrice[i] * matrice[i + 1] : + matrice[i] * _m_cumulate(matrice, i + 1); function m_cumulate(matrice) = len(matrice) == 1 ? matrice[0] : _m_cumulate(matrice, 0); diff --git a/src/m_multiply.scad b/src/m_multiply.scad deleted file mode 100644 index aff773a2..00000000 --- a/src/m_multiply.scad +++ /dev/null @@ -1,13 +0,0 @@ -/** -* m_multiply.scad -* -* @copyright Justin Lin, 2019 -* @license https://opensource.org/licenses/lgpl-3.0.html -* -* @see https://openhome.cc/eGossip/OpenSCAD/lib-m_multiply.html -* -**/ - -include <__private__/__m_multiply.scad>; - -function m_multiply(ma, mb) = __m_multiply(ma, mb); \ No newline at end of file diff --git a/src/m_rotation.scad b/src/m_rotation.scad index 7c0ff818..785bc421 100644 --- a/src/m_rotation.scad +++ b/src/m_rotation.scad @@ -8,8 +8,6 @@ * **/ -include <__private__/__m_multiply.scad>; - function _q_rotation(a, v) = let( half_a = a / 2, @@ -77,11 +75,7 @@ function _to_avect(a) = function _xyz_rotation(a) = let(ang = _to_avect(a)) - __m_multiply( - _m_zRotation(ang[2]), __m_multiply( - _m_yRotation(ang[1]), _m_xRotation(ang[0]) - ) - ); + _m_zRotation(ang[2]) * _m_yRotation(ang[1]) * _m_xRotation(ang[0]); function m_rotation(a, v) = v == undef ? _xyz_rotation(a) : _q_rotation(a, v); \ No newline at end of file diff --git a/src/m_shearing.scad b/src/m_shearing.scad index d09c10e6..84b20db2 100644 --- a/src/m_shearing.scad +++ b/src/m_shearing.scad @@ -8,7 +8,6 @@ * **/ -include <__private__/__m_multiply.scad>; include <__private__/__m_shearing.scad>; function m_shearing(sx = [0, 0], sy = [0, 0], sz = [0, 0]) = __m_shearing(sx, sy, sz); \ No newline at end of file diff --git a/src/path_extrude.scad b/src/path_extrude.scad index 447462f3..6faf7fe7 100644 --- a/src/path_extrude.scad +++ b/src/path_extrude.scad @@ -11,7 +11,6 @@ include <__private__/__is_vector.scad>; include <__private__/__to3d.scad>; include <__private__/__angy_angz.scad>; -include <__private__/__m_multiply.scad>; // Becuase of improving the performance, this module requires m_rotation.scad which doesn't require in dotSCAD 1.0. // For backward compatibility, I directly include m_rotation here. @@ -74,7 +73,7 @@ module path_extrude(shape_pts, path_pts, triangles = "SOLID", twist = 0, scale = i == leng_rot_matrice - 2 ? [ rot_matrice[leng_rot_matrice_minus_one], - __m_multiply(rot_matrice[leng_rot_matrice_minus_two], rot_matrice[leng_rot_matrice_minus_one]) + rot_matrice[leng_rot_matrice_minus_two] * rot_matrice[leng_rot_matrice_minus_one] ] : cumulated_rot_matrice_sub(i); @@ -84,7 +83,7 @@ module path_extrude(shape_pts, path_pts, triangles = "SOLID", twist = 0, scale = curr_matrix = rot_matrice[i], prev_matrix = matrice[len(matrice) - 1] ) - concat(matrice, [__m_multiply(curr_matrix, prev_matrix)]); + concat(matrice, [curr_matrix * prev_matrix]); cumu_rot_matrice = cumulated_rot_matrice(0); diff --git a/src/shear.scad b/src/shear.scad index ad853543..41c2f089 100644 --- a/src/shear.scad +++ b/src/shear.scad @@ -8,7 +8,6 @@ * **/ -include <__private__/__m_multiply.scad>; include <__private__/__m_shearing.scad>; module shear(sx = [0, 0], sy = [0, 0], sz = [0, 0]) {