mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-08-27 03:34:28 +02:00
Added polyhedra.scad
This commit is contained in:
@@ -61,6 +61,20 @@ module test_constrain() {
|
||||
test_constrain();
|
||||
|
||||
|
||||
module test_approx() {
|
||||
assert(approx(PI, 3.141592653589793236) == true);
|
||||
assert(approx(PI, 3.1415926) == false);
|
||||
assert(approx(PI, 3.1415926, eps=1e-6) == true);
|
||||
assert(approx(-PI, -3.141592653589793236) == true);
|
||||
assert(approx(-PI, -3.1415926) == false);
|
||||
assert(approx(-PI, -3.1415926, eps=1e-6) == true);
|
||||
assert(approx(1/3, 0.3333333333) == true);
|
||||
assert(approx(-1/3, -0.3333333333) == true);
|
||||
assert(approx(10*[cos(30),sin(30)], 10*[sqrt(3)/2, 1/2]) == true);
|
||||
}
|
||||
test_approx();
|
||||
|
||||
|
||||
module test_min_index() {
|
||||
vals = rands(-100,100,100);
|
||||
minval = min(vals);
|
||||
@@ -115,6 +129,17 @@ module test_modrange() {
|
||||
test_modrange();
|
||||
|
||||
|
||||
module test_sqr() {
|
||||
assert(sqr(-3) == 9);
|
||||
assert(sqr(0) == 0);
|
||||
assert(sqr(1) == 1);
|
||||
assert(sqr(2) == 4);
|
||||
assert(sqr(3) == 9);
|
||||
assert(sqr(16) == 256);
|
||||
}
|
||||
test_sqr();
|
||||
|
||||
|
||||
// TODO: Tests for gaussian_rand()
|
||||
// TODO: Tests for log_rand()
|
||||
|
||||
|
46
tests/test_polyhedra.scad
Normal file
46
tests/test_polyhedra.scad
Normal file
@@ -0,0 +1,46 @@
|
||||
include<BOSL2/std.scad>
|
||||
include<BOSL2/polyhedra.scad>
|
||||
|
||||
|
||||
$fn=96;
|
||||
|
||||
if (true) {
|
||||
|
||||
// Display of all solids with insphere, midsphere and circumsphere
|
||||
|
||||
for(i=[0:len(_polyhedra_)-1]) {
|
||||
place_copies([[3*i,0,0]]) // Plain polyhedron
|
||||
regular_polyhedron(index=i, mr=1,facedown=true);
|
||||
place_copies([[3*i,3.5,0]]){ // Inner radius means sphere touches faces of the polyhedron
|
||||
sphere(r=1.005); // Sphere is slightly oversized so you can see it poking out from each face
|
||||
%regular_polyhedron(index=i, ir=1,facedown=true);
|
||||
}
|
||||
place_copies([[3*i,7,0]]){ // Mid radius means the sphere touches the center of each edge
|
||||
sphere(r=1);
|
||||
%regular_polyhedron(index=i, mr=1,facedown=true);
|
||||
}
|
||||
place_copies([[3*i,11,0]]){ // outer radius means points of the polyhedron are on the sphere
|
||||
%sphere(r=.99); // Slightly undersized sphere means the points poke out a bit
|
||||
regular_polyhedron(index=i, or=1,facedown=true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Examples start here: not part of library
|
||||
|
||||
|
||||
|
||||
/*
|
||||
// Test that rounded shapes are the same size as unrounded
|
||||
shape = "dodecahedron";
|
||||
//shape = "cube";
|
||||
top_half(cp=[0,0,.2])
|
||||
difference(){
|
||||
regular_polyhedron(shape);
|
||||
regular_polyhedron(shape, rounding=0.2,side=1.0000);
|
||||
}
|
||||
*/
|
Reference in New Issue
Block a user