diff --git a/skin.scad b/skin.scad index 98d8b21..acd00fd 100644 --- a/skin.scad +++ b/skin.scad @@ -96,10 +96,12 @@ function skin(profiles, closed=false, caps=true, matching="distance") = cp1 = mean(prof1), cp2 = mean(prof2), midpt = (cp1+cp2)/2, - n = normalize(cp2-cp1), n1 = plane_normal(plane_from_pointslist(prof1)), n2 = plane_normal(plane_from_pointslist(prof2)), - perp = vector_angle(n1,n2)>0.01? vector_axis(n1,n2) : vector_angle(n,UP)>44? vector_axis(n,UP) : vector_axis(n,LEFT), + vang = vector_angle(n1,n2), + perp = vang>0.01 && vang<179.99? vector_axis(n1,n2) : + vector_angle(n1,UP)>44? vector_axis(n1,UP) : + vector_axis(n1,LEFT), perp1 = vector_axis(n1,perp), perp2 = vector_axis(n2,perp), poly1 = ccw_polygon(project_plane(prof1, cp1, cp1+perp, cp1+perp1)), diff --git a/tests/test_skin.scad b/tests/test_skin.scad new file mode 100644 index 0000000..ecc7849 --- /dev/null +++ b/tests/test_skin.scad @@ -0,0 +1,19 @@ +include +include + + +module test_skin() { + profiles = [ + [[-100,-100,0], [0,100,0], [100,-100,0]], + [[-100,-100,100], [-100,100,100], [100,100,100], [100,-100,100]], + ]; + vnf1 = skin(profiles, caps=false, matching="distance"); + assert(vnf1 == [[[-100,-100,0],[-100,100,100],[-100,-100,100],[0,100,0],[100,100,100],[100,-100,0],[100,-100,100]],[[0,1,2],[0,3,1],[3,4,1],[3,5,4],[5,6,4],[5,2,6],[5,0,2]]]); + vnf2 = skin(profiles, caps=true, matching="distance"); + assert(vnf2 == [[[-100,-100,0],[-100,100,100],[-100,-100,100],[0,100,0],[100,100,100],[100,-100,0],[100,-100,100],[100,-100,0],[0,100,0],[-100,-100,0],[-100,-100,100],[-100,100,100],[100,100,100],[100,-100,100]],[[0,1,2],[0,3,1],[3,4,1],[3,5,4],[5,6,4],[5,2,6],[5,0,2],[7,8,9],[10,11,12],[12,13,10]]]); + vnf_polyhedron(vnf2); +} +test_skin(); + + +// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap diff --git a/version.scad b/version.scad index bf2fa80..cf05edb 100644 --- a/version.scad +++ b/version.scad @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,15]; +BOSL_VERSION = [2,0,16]; // Section: BOSL Library Version Functions