mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-02-18 17:39:37 +00:00
Bugfix for line_of()
This commit is contained in:
parent
0b342bea6f
commit
c967b507a6
3 changed files with 26 additions and 1 deletions
|
@ -130,7 +130,7 @@ function line_of(spacing, n, l, p1, p2) =
|
||||||
assert(is_undef(p2) || is_vector(p2))
|
assert(is_undef(p2) || is_vector(p2))
|
||||||
let(
|
let(
|
||||||
ll = !is_undef(l)? scalar_vec3(l, 0) :
|
ll = !is_undef(l)? scalar_vec3(l, 0) :
|
||||||
(!is_undef(spacing) && !is_undef(n))? (n * scalar_vec3(spacing, 0)) :
|
(!is_undef(spacing) && !is_undef(n))? ((n-1) * scalar_vec3(spacing, 0)) :
|
||||||
(!is_undef(p1) && !is_undef(p2))? point3d(p2-p1) :
|
(!is_undef(p1) && !is_undef(p2))? point3d(p2-p1) :
|
||||||
undef,
|
undef,
|
||||||
cnt = !is_undef(n)? n :
|
cnt = !is_undef(n)? n :
|
||||||
|
|
19
tests/test_distributors.scad
Normal file
19
tests/test_distributors.scad
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
include <../std.scad>
|
||||||
|
|
||||||
|
|
||||||
|
module test_line_of() {
|
||||||
|
assert_equal(line_of(l=100,n=5), [[-50,0,0],[-25,0,0],[0,0,0],[25,0,0],[50,0,0]]);
|
||||||
|
assert_equal(line_of(20,n=5), [[-40,0,0],[-20,0,0],[0,0,0],[20,0,0],[40,0,0]]);
|
||||||
|
assert_equal(line_of(spacing=20,n=5), [[-40,0,0],[-20,0,0],[0,0,0],[20,0,0],[40,0,0]]);
|
||||||
|
assert_equal(line_of(spacing=[0,20],n=5), [[0,-40,0],[0,-20,0],[0,0,0],[0,20,0],[0,40,0]]);
|
||||||
|
|
||||||
|
assert_equal(line_of(p1=[0,0],l=100,n=5), [[0,0,0],[25,0,0],[50,0,0],[75,0,0],[100,0,0]]);
|
||||||
|
assert_equal(line_of(p1=[0,0],20,n=5), [[0,0,0],[20,0,0],[40,0,0],[60,0,0],[80,0,0]]);
|
||||||
|
assert_equal(line_of(p1=[0,0],spacing=20,n=5), [[0,0,0],[20,0,0],[40,0,0],[60,0,0],[80,0,0]]);
|
||||||
|
assert_equal(line_of(p1=[0,0],spacing=[0,20],n=5), [[0,0,0],[0,20,0],[0,40,0],[0,60,0],[0,80,0]]);
|
||||||
|
}
|
||||||
|
test_line_of();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
|
@ -242,5 +242,11 @@ module test_mask2d_ogee() {
|
||||||
test_mask2d_ogee();
|
test_mask2d_ogee();
|
||||||
|
|
||||||
|
|
||||||
|
module test_dashed_stroke() {
|
||||||
|
segs = dashed_stroke([[0,0],[10,0]], dashpat=[3,2], closed=false);
|
||||||
|
assert_equal(segs,[[[0,0],[3,0]], [[5,0],[8,0]]]);
|
||||||
|
}
|
||||||
|
test_dashed_stroke();
|
||||||
|
|
||||||
|
|
||||||
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
||||||
|
|
Loading…
Reference in a new issue