mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-01 09:49:45 +00:00
Added clarifying docs to vnf_centroid and vnf_volume. Changed vsqr to sqr
This commit is contained in:
parent
20c6e0fe72
commit
79358ddf6f
1 changed files with 8 additions and 5 deletions
13
vnf.scad
13
vnf.scad
|
@ -340,7 +340,9 @@ module vnf_polyhedron(vnf, convexity=2) {
|
||||||
// Usage:
|
// Usage:
|
||||||
// vol = vnf_volume(vnf);
|
// vol = vnf_volume(vnf);
|
||||||
// Description:
|
// Description:
|
||||||
// Returns the volume enclosed by the given manifold VNF. May return a negative value if faces are reversed.
|
// Returns the volume enclosed by the given manifold VNF. The VNF must describe a valid polyhedron with consistent face direction and
|
||||||
|
// 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.
|
||||||
function vnf_volume(vnf) =
|
function vnf_volume(vnf) =
|
||||||
let(vnf = vnf_triangulate(vnf))
|
let(vnf = vnf_triangulate(vnf))
|
||||||
sum([
|
sum([
|
||||||
|
@ -355,7 +357,8 @@ function vnf_volume(vnf) =
|
||||||
// Usage:
|
// Usage:
|
||||||
// vol = vnf_centroid(vnf);
|
// vol = vnf_centroid(vnf);
|
||||||
// Description:
|
// Description:
|
||||||
// Returns the centroid of the given manifold VNF.
|
// Returns the centroid of the given manifold VNF. The VNF must describe a valid polyhedron with consistent face direction and
|
||||||
|
// no holes; otherwise the results are undefined.
|
||||||
function vnf_centroid(vnf) =
|
function vnf_centroid(vnf) =
|
||||||
let(
|
let(
|
||||||
vnf = vnf_triangulate(vnf),
|
vnf = vnf_triangulate(vnf),
|
||||||
|
@ -367,9 +370,9 @@ function vnf_centroid(vnf) =
|
||||||
) [
|
) [
|
||||||
face[0] * n,
|
face[0] * n,
|
||||||
vmul(n,
|
vmul(n,
|
||||||
vsqr(face[0] + face[1]) +
|
sqr(face[0] + face[1]) +
|
||||||
vsqr(face[0] + face[2]) +
|
sqr(face[0] + face[2]) +
|
||||||
vsqr(face[1] + face[2])
|
sqr(face[1] + face[2])
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
])
|
])
|
||||||
|
|
Loading…
Reference in a new issue