mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-10 00:36:40 +02:00
use built-in matrix multi
This commit is contained in:
@@ -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]
|
|
||||||
];
|
|
@@ -7,11 +7,10 @@
|
|||||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib-along_with.html
|
* @see https://openhome.cc/eGossip/OpenSCAD/lib-along_with.html
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
include <__private__/__angy_angz.scad>;
|
include <__private__/__angy_angz.scad>;
|
||||||
include <__private__/__is_vector.scad>;
|
include <__private__/__is_vector.scad>;
|
||||||
include <__private__/__to3d.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.
|
// 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.
|
// 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 ?
|
i == leng_rot_matrice - 2 ?
|
||||||
[
|
[
|
||||||
rot_matrice[leng_rot_matrice_minus_one],
|
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);
|
: 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],
|
curr_matrix = rot_matrice[i],
|
||||||
prev_matrix = matrice[len(matrice) - 1]
|
prev_matrix = matrice[len(matrice) - 1]
|
||||||
)
|
)
|
||||||
concat(matrice, [__m_multiply(curr_matrix, prev_matrix)]);
|
concat(matrice, [curr_matrix * prev_matrix]);
|
||||||
|
|
||||||
// align modules
|
// align modules
|
||||||
|
|
||||||
|
@@ -8,12 +8,10 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
include <__private__/__m_multiply.scad>;
|
|
||||||
|
|
||||||
function _m_cumulate(matrice, i) =
|
function _m_cumulate(matrice, i) =
|
||||||
i == len(matrice) - 2 ?
|
i == len(matrice) - 2 ?
|
||||||
__m_multiply(matrice[i], matrice[i + 1]) :
|
matrice[i] * matrice[i + 1] :
|
||||||
__m_multiply(matrice[i], _m_cumulate(matrice, i + 1));
|
matrice[i] * _m_cumulate(matrice, i + 1);
|
||||||
|
|
||||||
function m_cumulate(matrice) =
|
function m_cumulate(matrice) =
|
||||||
len(matrice) == 1 ? matrice[0] : _m_cumulate(matrice, 0);
|
len(matrice) == 1 ? matrice[0] : _m_cumulate(matrice, 0);
|
||||||
|
@@ -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);
|
|
@@ -8,8 +8,6 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
include <__private__/__m_multiply.scad>;
|
|
||||||
|
|
||||||
function _q_rotation(a, v) =
|
function _q_rotation(a, v) =
|
||||||
let(
|
let(
|
||||||
half_a = a / 2,
|
half_a = a / 2,
|
||||||
@@ -77,11 +75,7 @@ function _to_avect(a) =
|
|||||||
|
|
||||||
function _xyz_rotation(a) =
|
function _xyz_rotation(a) =
|
||||||
let(ang = _to_avect(a))
|
let(ang = _to_avect(a))
|
||||||
__m_multiply(
|
_m_zRotation(ang[2]) * _m_yRotation(ang[1]) * _m_xRotation(ang[0]);
|
||||||
_m_zRotation(ang[2]), __m_multiply(
|
|
||||||
_m_yRotation(ang[1]), _m_xRotation(ang[0])
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
function m_rotation(a, v) =
|
function m_rotation(a, v) =
|
||||||
v == undef ? _xyz_rotation(a) : _q_rotation(a, v);
|
v == undef ? _xyz_rotation(a) : _q_rotation(a, v);
|
@@ -8,7 +8,6 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
include <__private__/__m_multiply.scad>;
|
|
||||||
include <__private__/__m_shearing.scad>;
|
include <__private__/__m_shearing.scad>;
|
||||||
|
|
||||||
function m_shearing(sx = [0, 0], sy = [0, 0], sz = [0, 0]) = __m_shearing(sx, sy, sz);
|
function m_shearing(sx = [0, 0], sy = [0, 0], sz = [0, 0]) = __m_shearing(sx, sy, sz);
|
@@ -11,7 +11,6 @@
|
|||||||
include <__private__/__is_vector.scad>;
|
include <__private__/__is_vector.scad>;
|
||||||
include <__private__/__to3d.scad>;
|
include <__private__/__to3d.scad>;
|
||||||
include <__private__/__angy_angz.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.
|
// 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.
|
// 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 ?
|
i == leng_rot_matrice - 2 ?
|
||||||
[
|
[
|
||||||
rot_matrice[leng_rot_matrice_minus_one],
|
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);
|
: 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],
|
curr_matrix = rot_matrice[i],
|
||||||
prev_matrix = matrice[len(matrice) - 1]
|
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);
|
cumu_rot_matrice = cumulated_rot_matrice(0);
|
||||||
|
|
||||||
|
@@ -8,7 +8,6 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
include <__private__/__m_multiply.scad>;
|
|
||||||
include <__private__/__m_shearing.scad>;
|
include <__private__/__m_shearing.scad>;
|
||||||
|
|
||||||
module shear(sx = [0, 0], sy = [0, 0], sz = [0, 0]) {
|
module shear(sx = [0, 0], sy = [0, 0], sz = [0, 0]) {
|
||||||
|
Reference in New Issue
Block a user