1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-17 04:04:16 +02:00
This commit is contained in:
Justin Lin
2020-01-27 15:13:08 +08:00
parent 3ae3029b57
commit 4b0974807c
2 changed files with 25 additions and 88 deletions

View File

@@ -8,8 +8,8 @@
* *
**/ **/
include <__comm__/__frags.scad>; use <__comm__/__frags.scad>;
include <__comm__/__nearest_multiple_of_4.scad>; use <__comm__/__nearest_multiple_of_4.scad>;
module line3d(p1, p2, thickness, p1Style = "CAP_CIRCLE", p2Style = "CAP_CIRCLE") { module line3d(p1, p2, thickness, p1Style = "CAP_CIRCLE", p2Style = "CAP_CIRCLE") {
r = thickness / 2; r = thickness / 2;

View File

@@ -1,4 +1,5 @@
include <unittest.scad>; use <unittest.scad>;
use <line3d.scad>;
module test_line3d() { module test_line3d() {
p1 = [0, 0, 0]; p1 = [0, 0, 0];
@@ -6,97 +7,33 @@ module test_line3d() {
thickness = 1; thickness = 1;
fn = 24; fn = 24;
module test_line3d_default_caps() { echo("==== test_line3d_default_caps ====");
echo("==== test_line3d_default_caps ====");
include <line3d.scad>; module test_line3d_butt(p, r, frags, length, angles) {
assertEqualPoint(p1, p);
module test_line3d_butt(p, r, frags, length, angles) { assertEqualNum(thickness / 2, r);
assertEqualPoint(p1, p); assertEqualNum(fn, frags);
assertEqualNum(thickness / 2, r); assertEqualNum(14.2829, length);
assertEqualNum(fn, frags); assertEqualPoint([0, 45.5618, 11.3099], angles);
assertEqualNum(14.2829, length);
assertEqualPoint([0, 45.5618, 11.3099], angles);
}
module test_line3d_cap(p, r, frags, cap_leng, angles) {
assert(p == p1 || p == p2);
assertEqualNum(thickness / 2, r);
assertEqualNum(fn, frags);
assertEqualNum(0.3536, cap_leng);
assertEqualPoint([0, 45.5618, 11.3099], angles);
}
line3d(
p1 = p1,
p2 = p2,
thickness = thickness,
$fn = fn
);
} }
module test_line3d_cap_butt() { module test_line3d_cap(p, r, frags, cap_leng, angles) {
echo("==== test_line3d_cap_butt ===="); assert(p == p1 || p == p2);
assertEqualNum(thickness / 2, r);
include <line3d.scad>; assertEqualNum(fn, frags);
assertEqualNum(0.3536, cap_leng);
module test_line3d_butt(p, r, frags, length, angles) { assertEqualPoint([0, 45.5618, 11.3099], angles);
assertEqualPoint(p1, p);
assertEqualNum(thickness / 2, r);
assertEqualNum(fn, frags);
assertEqualNum(14.2829, length);
assertEqualPoint([0, 45.5618, 11.3099], angles);
}
module test_line3d_cap(p, r, frags, cap_leng, angles) {
fail("Should not be invoked!!");
}
line3d(
p1 = p1,
p2 = p2,
thickness = thickness,
p1Style = "CAP_BUTT",
p2Style = "CAP_BUTT",
$fn = fn
);
} }
module test_line3d_cap_sphere() {
echo("==== test_line3d_cap_sphere ====");
include <line3d.scad>; line3d(
p1 = p1,
module test_line3d_butt(p, r, frags, length, angles) { p2 = p2,
assertEqualPoint(p1, p); thickness = thickness,
assertEqualNum(thickness / 2, r); $fn = fn
assertEqualNum(fn, frags); );
assertEqualNum(14.2829, length);
assertEqualPoint([0, 45.5618, 11.3099], angles);
}
module test_line3d_cap(p, r, frags, cap_leng, angles) {
assert(p == p1 || p == p2);
assertEqualNum(thickness / 2, r);
assertEqualNum(fn, frags);
assertEqualNum(0.5043, cap_leng);
assertEqualPoint([0, 45.5618, 11.3099], angles);
}
line3d(
p1 = p1,
p2 = p2,
thickness = thickness,
p1Style = "CAP_SPHERE",
p2Style = "CAP_SPHERE",
$fn = fn
);
}
test_line3d_default_caps(); test_line3d_default_caps();
test_line3d_cap_butt();
test_line3d_cap_sphere();
} }
test_line3d(); test_line3d();