Merge branch 'master' of github.com:revarbat/BOSL2

This commit is contained in:
Revar Desmera 2020-03-30 16:52:23 -07:00
commit 584b56f8da

View file

@ -345,6 +345,9 @@ module vnf_polyhedron(vnf, convexity=2) {
} }
// Function: vnf_volume() // Function: vnf_volume()
// Usage: // Usage:
// vol = vnf_volume(vnf); // vol = vnf_volume(vnf);
@ -353,13 +356,14 @@ module vnf_polyhedron(vnf, convexity=2) {
// no holes; otherwise the results are undefined. Returns a positive volume if face direction is clockwise and a negative volume // no holes; otherwise the results are undefined. Returns a positive volume if face direction is clockwise and a negative volume
// if face direction is counter-clockwise. // if face direction is counter-clockwise.
function vnf_volume(vnf) = function vnf_volume(vnf) =
let(vnf = vnf_triangulate(vnf)) let(vnf = vnf_triangulate(vnf),
sum([ vert=vnf[0])
for(face_index=vnf[1]) let( sum([
face = select(vnf[0], face_index), for(face_index=vnf[1]) let(
n = cross(face[2]-face[0],face[1]-face[0]) face = select(vert, face_index),
) face[0] * n n = cross(face[2]-face[0],face[1]-face[0])
])/6; ) face[0] * n
])/6;
// Function: vnf_centroid() // Function: vnf_centroid()
@ -373,10 +377,11 @@ function vnf_volume(vnf) =
function vnf_centroid(vnf) = function vnf_centroid(vnf) =
let( let(
vnf = vnf_triangulate(vnf), vnf = vnf_triangulate(vnf),
vert = vnf[0],
val=sum([ val=sum([
for(face_index=vnf[1]) for(face_index=vnf[1])
let( let(
face = select(vnf[0], face_index), face = select(vert, face_index),
n = cross(face[2]-face[0],face[1]-face[0]) n = cross(face[2]-face[0],face[1]-face[0])
) [ ) [
face[0] * n, face[0] * n,