mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-12 01:34:12 +02:00
refactored
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
include <unittest.scad>;
|
||||
|
||||
echo("==== test_rounded_square ====");
|
||||
|
||||
module test_rounded_square_size_corner() {
|
||||
echo("==== test_rounded_square_size_corner ====");
|
||||
|
||||
include <rounded_square.scad>;
|
||||
|
||||
module test_rounded_square(position, points) {
|
||||
@@ -17,6 +17,8 @@ module test_rounded_square_size_corner() {
|
||||
}
|
||||
|
||||
module test_rounded_square_size_corner_center() {
|
||||
echo("==== test_rounded_square_size_corner_center ====");
|
||||
|
||||
include <rounded_square.scad>;
|
||||
|
||||
module test_rounded_square(position, points) {
|
||||
@@ -35,6 +37,8 @@ module test_rounded_square_size_corner_center() {
|
||||
}
|
||||
|
||||
module test_rounded_square_size_corner_center_fn() {
|
||||
echo("==== test_rounded_square_size_corner_center_fn ====");
|
||||
|
||||
include <rounded_square.scad>;
|
||||
|
||||
module test_rounded_square(position, points) {
|
||||
|
@@ -1,11 +1,14 @@
|
||||
include <unittest.scad>;
|
||||
include <shape_arc.scad>;
|
||||
|
||||
echo("==== test_shape_arc ====");
|
||||
module test_shape_arc() {
|
||||
echo("==== test_shape_arc ====");
|
||||
|
||||
expected = [[0, -12.4315], [1.30661, -12.4315], [3.86271, -11.8882], [6.25, -10.8253], [8.36413, -9.28931], [10.1127, -7.34732], [11.4193, -5.08421], [12.2268, -2.5989], [12.5, 0], [12.2268, 2.5989], [11.4193, 5.08421], [10.1127, 7.34732], [8.36413, 9.28931], [6.25, 10.8253], [3.86271, 11.8882], [1.30661, 12.4315], [0, 12.4315], [0, 7.45891], [0.783963, 7.45891], [2.31763, 7.13292], [3.75, 6.49519], [5.01848, 5.57359], [6.06763, 4.40839], [6.85159, 3.05052], [7.33611, 1.55934], [7.5, 0], [7.33611, -1.55934], [6.85159, -3.05052], [6.06763, -4.40839], [5.01848, -5.57359], [3.75, -6.49519], [2.31763, -7.13292], [0.783963, -7.45891], [0, -7.45891]];
|
||||
expected = [[0, -12.4315], [1.30661, -12.4315], [3.86271, -11.8882], [6.25, -10.8253], [8.36413, -9.28931], [10.1127, -7.34732], [11.4193, -5.08421], [12.2268, -2.5989], [12.5, 0], [12.2268, 2.5989], [11.4193, 5.08421], [10.1127, 7.34732], [8.36413, 9.28931], [6.25, 10.8253], [3.86271, 11.8882], [1.30661, 12.4315], [0, 12.4315], [0, 7.45891], [0.783963, 7.45891], [2.31763, 7.13292], [3.75, 6.49519], [5.01848, 5.57359], [6.06763, 4.40839], [6.85159, 3.05052], [7.33611, 1.55934], [7.5, 0], [7.33611, -1.55934], [6.85159, -3.05052], [6.06763, -4.40839], [5.01848, -5.57359], [3.75, -6.49519], [2.31763, -7.13292], [0.783963, -7.45891], [0, -7.45891]];
|
||||
|
||||
actual = shape_arc(radius = 10, angle = [-90, 90], width = 5);
|
||||
actual = shape_arc(radius = 10, angle = [-90, 90], width = 5);
|
||||
|
||||
assertEqualPoints(expected, actual);
|
||||
assertEqualPoints(expected, actual);
|
||||
}
|
||||
|
||||
test_shape_arc();
|
34
test/test_shape_cyclicpolygon.scad
Normal file
34
test/test_shape_cyclicpolygon.scad
Normal file
@@ -0,0 +1,34 @@
|
||||
include <unittest.scad>;
|
||||
include <shape_cyclicpolygon.scad>;
|
||||
|
||||
module test_shape_cyclicpolygon() {
|
||||
echo("==== test_shape_cyclicpolygon ====");
|
||||
|
||||
expected_all = [
|
||||
[[5.5, -2.59808], [6.12132, -2.12132], [6.59808, -1.5], [6.89778, -0.776457], [7, 0], [6.89778, 0.776457], [6.59808, 1.5], [6.12132, 2.12132], [5.5, 2.59808], [-0.5, 6.06218], [-1.22354, 6.36188], [-2, 6.4641], [-2.77646, 6.36188], [-3.5, 6.06218], [-4.12132, 5.58542], [-4.59808, 4.9641], [-4.89778, 4.24056], [-5, 3.4641], [-5, -3.4641], [-4.89778, -4.24056], [-4.59808, -4.9641], [-4.12132, -5.58542], [-3.5, -6.06218], [-2.77646, -6.36188], [-2, -6.4641], [-1.22354, -6.36188], [-0.5, -6.06218]],
|
||||
|
||||
[[7.87868, -2.12132], [8.35544, -1.5], [8.65514, -0.776457], [8.75736, 0], [8.65514, 0.776457], [8.35544, 1.5], [7.87868, 2.12132], [2.12132, 7.87868], [1.5, 8.35544], [0.776457, 8.65514], [0, 8.75736], [-0.776457, 8.65514], [-1.5, 8.35544], [-2.12132, 7.87868], [-7.87868, 2.12132], [-8.35544, 1.5], [-8.65514, 0.776457], [-8.75736, 0], [-8.65514, -0.776457], [-8.35544, -1.5], [-7.87868, -2.12132], [-2.12132, -7.87868], [-1.5, -8.35544], [-0.776457, -8.65514], [0, -8.75736], [0.776457, -8.65514], [1.5, -8.35544], [2.12132, -7.87868]],
|
||||
|
||||
[[8.71885, -1.76336], [9.09254, -1.0751], [9.27536, -0.313585], [9.25486, 0.469303], [9.03243, 1.22021], [8.71885, 1.76336], [4.37132, 7.74721], [3.83223, 8.31529], [3.16448, 8.72449], [2.41358, 8.94692], [1.63069, 8.96742], [1.01722, 8.83702], [-6.01722, 6.55139], [-6.72409, 6.21424], [-7.3196, 5.70562], [-7.76319, 5.0602], [-8.02461, 4.32196], [-8.09017, 3.69822], [-8.09017, -3.69822], [-7.98795, -4.47468], [-7.68825, -5.19822], [-7.21149, -5.81955], [-6.59017, -6.2963], [-6.01722, -6.55139], [1.01722, -8.83702], [1.78726, -8.97974], [2.56801, -8.9183], [3.30624, -8.65687], [3.95166, -8.21329], [4.37132, -7.74721]],
|
||||
|
||||
[[9.13397, -1.5], [9.43368, -0.776457], [9.5359, 0], [9.43368, 0.776457], [9.13397, 1.5], [5.86603, 7.16025], [5.38927, 7.78157], [4.76795, 8.25833], [4.04441, 8.55803], [3.26795, 8.66025], [-3.26795, 8.66025], [-4.04441, 8.55803], [-4.76795, 8.25833], [-5.38927, 7.78157], [-5.86603, 7.16025], [-9.13397, 1.5], [-9.43368, 0.776457], [-9.5359, 0], [-9.43368, -0.776457], [-9.13397, -1.5], [-5.86603, -7.16025], [-5.38927, -7.78157], [-4.76795, -8.25833], [-4.04441, -8.55803], [-3.26795, -8.66025], [3.26795, -8.66025], [4.04441, -8.55803], [4.76795, -8.25833], [5.38927, -7.78157], [5.86603, -7.16025]]
|
||||
];
|
||||
|
||||
circle_r = 10;
|
||||
corner_r = 3;
|
||||
|
||||
$fn = 24;
|
||||
|
||||
for(i = [0:3]) {
|
||||
actual = shape_cyclicpolygon(
|
||||
sides = 3 + i,
|
||||
circle_r = circle_r,
|
||||
corner_r = corner_r
|
||||
);
|
||||
|
||||
assertEqualPoints(expected_all[i], actual);
|
||||
}
|
||||
}
|
||||
|
||||
test_shape_cyclicpolygon();
|
||||
|
@@ -1,10 +1,14 @@
|
||||
include <unittest.scad>;
|
||||
include <shape_ellipse.scad>;
|
||||
|
||||
echo("==== test_shape_ellipse ====");
|
||||
module test_shape_ellipse() {
|
||||
echo("==== test_shape_ellipse ====");
|
||||
|
||||
expected = [[40, 0], [39.1259, 4.15823], [36.5418, 8.13473], [32.3607, 11.7557], [26.7652, 14.8629], [20, 17.3205], [12.3607, 19.0211], [4.18114, 19.8904], [-4.18114, 19.8904], [-12.3607, 19.0211], [-20, 17.3205], [-26.7652, 14.8629], [-32.3607, 11.7557], [-36.5418, 8.13473], [-39.1259, 4.15823], [-40, 0], [-39.1259, -4.15823], [-36.5418, -8.13473], [-32.3607, -11.7557], [-26.7652, -14.8629], [-20, -17.3205], [-12.3607, -19.0211], [-4.18114, -19.8904], [4.18114, -19.8904], [12.3607, -19.0211], [20, -17.3205], [26.7652, -14.8629], [32.3607, -11.7557], [36.5418, -8.13473], [39.1259, -4.15823]];
|
||||
expected = [[40, 0], [39.1259, 4.15823], [36.5418, 8.13473], [32.3607, 11.7557], [26.7652, 14.8629], [20, 17.3205], [12.3607, 19.0211], [4.18114, 19.8904], [-4.18114, 19.8904], [-12.3607, 19.0211], [-20, 17.3205], [-26.7652, 14.8629], [-32.3607, 11.7557], [-36.5418, 8.13473], [-39.1259, 4.15823], [-40, 0], [-39.1259, -4.15823], [-36.5418, -8.13473], [-32.3607, -11.7557], [-26.7652, -14.8629], [-20, -17.3205], [-12.3607, -19.0211], [-4.18114, -19.8904], [4.18114, -19.8904], [12.3607, -19.0211], [20, -17.3205], [26.7652, -14.8629], [32.3607, -11.7557], [36.5418, -8.13473], [39.1259, -4.15823]];
|
||||
|
||||
actual = shape_ellipse([40, 20]);
|
||||
actual = shape_ellipse([40, 20]);
|
||||
|
||||
assertEqualPoints(expected, actual);
|
||||
assertEqualPoints(expected, actual);
|
||||
}
|
||||
|
||||
test_shape_ellipse();
|
@@ -1,10 +1,14 @@
|
||||
include <unittest.scad>;
|
||||
include <shape_pie.scad>;
|
||||
|
||||
echo("==== test_shape_pie ====");
|
||||
module test_shape_pie() {
|
||||
echo("==== test_shape_pie ====");
|
||||
|
||||
expected = [[0, 0], [7.07107, 7.07107], [5, 8.66025], [2.58819, 9.65926], [0, 10], [-2.58819, 9.65926], [-5, 8.66025], [-7.07107, 7.07107], [-8.66025, 5], [-9.65926, 2.58819], [-10, 0], [-9.65926, -2.58819], [-8.66025, -5], [-7.07107, -7.07107], [-5, -8.66025], [-2.58819, -9.65926], [0, -10], [2.58819, -9.65926], [5, -8.66025], [7.07107, -7.07107]];
|
||||
expected = [[0, 0], [7.07107, 7.07107], [5, 8.66025], [2.58819, 9.65926], [0, 10], [-2.58819, 9.65926], [-5, 8.66025], [-7.07107, 7.07107], [-8.66025, 5], [-9.65926, 2.58819], [-10, 0], [-9.65926, -2.58819], [-8.66025, -5], [-7.07107, -7.07107], [-5, -8.66025], [-2.58819, -9.65926], [0, -10], [2.58819, -9.65926], [5, -8.66025], [7.07107, -7.07107]];
|
||||
|
||||
actual = shape_pie(10, [45, 315], $fn = 24);
|
||||
actual = shape_pie(10, [45, 315], $fn = 24);
|
||||
|
||||
assertEqualPoints(expected, actual);
|
||||
assertEqualPoints(expected, actual);
|
||||
}
|
||||
|
||||
test_shape_pie();
|
@@ -1,10 +1,14 @@
|
||||
include <unittest.scad>;
|
||||
include <shape_square.scad>;
|
||||
|
||||
echo("==== test_shape_square ====");
|
||||
module test_shape_square() {
|
||||
echo("==== test_shape_square ====");
|
||||
|
||||
expected = [[20, -25], [21.9471, -24.6053], [23.5868, -23.4835], [24.6602, -21.8118], [25, -20], [25, 20], [24.6053, 21.9471], [23.4835, 23.5868], [21.8118, 24.6602], [20, 25], [-20, 25], [-21.8118, 24.6602], [-23.4835, 23.5868], [-24.6053, 21.9471], [-25, 20], [-25, -20], [-24.6602, -21.8118], [-23.5868, -23.4835], [-21.9471, -24.6053], [-20, -25]];
|
||||
expected = [[20, -25], [21.9471, -24.6053], [23.5868, -23.4835], [24.6602, -21.8118], [25, -20], [25, 20], [24.6053, 21.9471], [23.4835, 23.5868], [21.8118, 24.6602], [20, 25], [-20, 25], [-21.8118, 24.6602], [-23.4835, 23.5868], [-24.6053, 21.9471], [-25, 20], [-25, -20], [-24.6602, -21.8118], [-23.5868, -23.4835], [-21.9471, -24.6053], [-20, -25]];
|
||||
|
||||
actual = shape_square(size = 50, corner_r = 5);
|
||||
actual = shape_square(size = 50, corner_r = 5);
|
||||
|
||||
assertEqualPoints(expected, actual);
|
||||
assertEqualPoints(expected, actual);
|
||||
}
|
||||
|
||||
test_shape_square();
|
@@ -1,15 +1,18 @@
|
||||
include <unittest.scad>;
|
||||
include <shape_trapezium.scad>;
|
||||
|
||||
echo("==== test_shape_trapezium ====");
|
||||
module test_shape_trapezium() {
|
||||
echo("==== test_shape_trapezium ====");
|
||||
|
||||
expected = [[16.7639, -10], [18.4469, -9.0806], [18.5825, -7.1677], [18.5528, -7.10557], [10.5528, 8.89443], [8.97782, 9.98853], [8.76393, 10], [-8.76393, 10], [-8.97782, 9.98853], [-10.5528, 8.89443], [-18.5528, -7.10557], [-18.5825, -7.1677], [-18.4469, -9.0806], [-16.7639, -10]];
|
||||
expected = [[16.7639, -10], [18.4469, -9.0806], [18.5825, -7.1677], [18.5528, -7.10557], [10.5528, 8.89443], [8.97782, 9.98853], [8.76393, 10], [-8.76393, 10], [-8.97782, 9.98853], [-10.5528, 8.89443], [-18.5528, -7.10557], [-18.5825, -7.1677], [-18.4469, -9.0806], [-16.7639, -10]];
|
||||
|
||||
actual = shape_trapezium(
|
||||
[40, 20],
|
||||
h = 20,
|
||||
corner_r = 2
|
||||
);
|
||||
actual = shape_trapezium(
|
||||
[40, 20],
|
||||
h = 20,
|
||||
corner_r = 2
|
||||
);
|
||||
|
||||
assertEqualPoints(expected, actual);
|
||||
assertEqualPoints(expected, actual);
|
||||
}
|
||||
|
||||
test_shape_trapezium();
|
||||
|
Reference in New Issue
Block a user