mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-09-17 01:52:11 +02:00
Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
665fb09864 | ||
|
f33d6c5671 | ||
|
f985e13231 | ||
|
7b1a683c74 | ||
|
ff8d36336e | ||
|
49be3b9b9f | ||
|
e13abc57ce | ||
|
6fbe42ba8f | ||
|
48e52fa48b | ||
|
0dbe93d16b | ||
|
bdaa05823c | ||
|
035e1fa1b4 |
@@ -104,7 +104,6 @@ Too many dependencies? Because OpenSCAD doesn't provide namespace management, I
|
||||
- [sphere_spiral_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-sphere_spiral_extrude.html)
|
||||
|
||||
- Matrix
|
||||
- [m_multiply](https://openhome.cc/eGossip/OpenSCAD/lib-m_multiply.html)
|
||||
- [m_cumulate](https://openhome.cc/eGossip/OpenSCAD/lib-m_cumulate.html)
|
||||
- [m_translation](https://openhome.cc/eGossip/OpenSCAD/lib-m_translation.html)
|
||||
- [m_rotation](https://openhome.cc/eGossip/OpenSCAD/lib-m_rotation.html)
|
||||
|
@@ -1,3 +1,12 @@
|
||||
# v1.1.1
|
||||
- Bugfixes
|
||||
- `m_rotation` returns an identity matrix if `a` is 0.
|
||||
- The `path_pts` parameter of `path_extrude` accepts two or three points.
|
||||
- The `points` parameter of `along_with` accepts two or three points.
|
||||
|
||||
- Others
|
||||
- OpenSCAD has built-in matrix multiplication so `m_multiply` is not necessary.
|
||||
|
||||
# v1.1
|
||||
- New matrix functions:
|
||||
- [m_multiply](https://openhome.cc/eGossip/OpenSCAD/lib-m_multiply.html)
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 22 KiB |
@@ -15,8 +15,8 @@ Creates an arc path. You can pass a 2 element vector to define the central angle
|
||||
include <hull_polyline2d.scad>;
|
||||
|
||||
$fn = 24;
|
||||
points = arc_path(radius = 20, angle = [45, 290], width = 2);
|
||||
hull_polyline2d(points);
|
||||
points = arc_path(radius = 20, angle = [45, 290]);
|
||||
hull_polyline2d(points, width = 2);
|
||||
|
||||

|
||||
|
||||
@@ -24,8 +24,8 @@ Creates an arc path. You can pass a 2 element vector to define the central angle
|
||||
include <hull_polyline2d.scad>;
|
||||
|
||||
$fn = 24;
|
||||
points = arc_path(radius = 20, angle = 135, width = 2);
|
||||
hull_polyline2d(points);
|
||||
points = arc_path(radius = 20, angle = 135);
|
||||
hull_polyline2d(points, width = 2);
|
||||
|
||||

|
||||
|
||||
|
@@ -1,23 +0,0 @@
|
||||
# m_mirror
|
||||
|
||||
Generate a 4x4 transformation matrix which can pass into `multmatrix` to mirror the child element on a plane through the origin.
|
||||
|
||||
**Since:** 1.1
|
||||
|
||||
## Parameters
|
||||
|
||||
- `v` : The normal vector of a plane intersecting the origin through which to mirror the object.
|
||||
|
||||
## Examples
|
||||
|
||||
include <m_mirror.scad>;
|
||||
|
||||
rotate([0, 0, 10])
|
||||
cube([3, 2, 1]);
|
||||
|
||||
multmatrix(m_mirror([1, 1, 0]))
|
||||
rotate([0, 0, 10])
|
||||
cube([3, 2, 1]);
|
||||
|
||||

|
||||
|
@@ -6,6 +6,7 @@ Returns shape points of a regular cyclic polygon. They can be used with xxx_extr
|
||||
|
||||
- `sides` : The radius of the circle.
|
||||
- `circle_r` : The radius of the circumcircle.
|
||||
- `corner_r` : The radius of the circle at a corner.
|
||||
- `$fa`, `$fs`, `$fn` : Check [the circle module](https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_the_2D_Subsystem#circle) for more details.
|
||||
|
||||
## Examples
|
||||
|
@@ -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
|
||||
*
|
||||
**/
|
||||
|
||||
|
||||
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.
|
||||
@@ -35,6 +34,13 @@ module along_with(points, angles, twist = 0, scale = 1.0) {
|
||||
|
||||
// get rotation matrice for sections
|
||||
|
||||
identity_matrix = [
|
||||
[1, 0, 0, 0],
|
||||
[0, 1, 0, 0],
|
||||
[0, 0, 1, 0],
|
||||
[0, 0, 0, 1]
|
||||
];
|
||||
|
||||
function local_ang_vects(j) =
|
||||
j == 0 ? [] : local_ang_vects_sub(j);
|
||||
|
||||
@@ -53,12 +59,16 @@ module along_with(points, angles, twist = 0, scale = 1.0) {
|
||||
leng_rot_matrice_minus_one = leng_rot_matrice - 1,
|
||||
leng_rot_matrice_minus_two = leng_rot_matrice - 2
|
||||
)
|
||||
i == leng_rot_matrice - 2 ?
|
||||
leng_rot_matrice == 0 ? [identity_matrix] : (
|
||||
leng_rot_matrice == 1 ? [rot_matrice[0], identity_matrix] : (
|
||||
i == leng_rot_matrice_minus_two ?
|
||||
[
|
||||
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)
|
||||
)
|
||||
);
|
||||
|
||||
function cumulated_rot_matrice_sub(i, rot_matrice) =
|
||||
let(
|
||||
@@ -66,7 +76,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
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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) =
|
||||
let(
|
||||
half_a = a / 2,
|
||||
@@ -77,11 +75,12 @@ 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);
|
||||
(a == 0 || a == [0, 0, 0] || a == [0] || a == [0, 0]) ? [
|
||||
[1, 0, 0, 0],
|
||||
[0, 1, 0, 0],
|
||||
[0, 0, 1, 0],
|
||||
[0, 0, 0, 1]
|
||||
] : (v == undef ? _xyz_rotation(a) : _q_rotation(a, v));
|
@@ -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);
|
@@ -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.
|
||||
@@ -70,13 +69,24 @@ module path_extrude(shape_pts, path_pts, triangles = "SOLID", twist = 0, scale =
|
||||
leng_rot_matrice_minus_one = leng_rot_matrice - 1;
|
||||
leng_rot_matrice_minus_two= leng_rot_matrice - 2;
|
||||
|
||||
identity_matrix = [
|
||||
[1, 0, 0, 0],
|
||||
[0, 1, 0, 0],
|
||||
[0, 0, 1, 0],
|
||||
[0, 0, 0, 1]
|
||||
];
|
||||
|
||||
function cumulated_rot_matrice(i) =
|
||||
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])
|
||||
]
|
||||
: cumulated_rot_matrice_sub(i);
|
||||
leng_rot_matrice == 0 ? [identity_matrix] : (
|
||||
leng_rot_matrice == 1 ? [rot_matrice[0], identity_matrix] :
|
||||
(
|
||||
i == 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))
|
||||
);
|
||||
|
||||
function cumulated_rot_matrice_sub(i) =
|
||||
let(
|
||||
@@ -84,7 +94,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);
|
||||
|
||||
|
@@ -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]) {
|
||||
|
Reference in New Issue
Block a user