b6dcdd163e
2 commits, squashed; the originals stay reachable from tag archive/merge-main-develop. - bcbb99005 jyviko: kernel, smlib: a blend larger than its faces is SMLib's refusal; blends take exactly the given edges - 13e49e069 jyviko: engine: solid.fillet and solid.chamfer say they blend exactly the edges given Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DtL5M41G8Nua7HvuFPZkmJ
15 lines
628 B
Rust
15 lines
628 B
Rust
//! The area vector of a loop of points (Newell's method): its normal and the area it encloses.
|
|
|
|
use solidcraft_geom::Vec3;
|
|
|
|
/// The area vector of a closed polygon (Newell's method): normal to the loop, as long as the area
|
|
/// it encloses, pointing the way the loop runs round by the right-hand rule.
|
|
pub(crate) fn loop_area(points: &[Vec3]) -> Vec3 {
|
|
let mut n = Vec3::ZERO;
|
|
for (i, p) in points.iter().enumerate() {
|
|
let Some(q) = points.get((i + 1) % points.len()) else { continue };
|
|
n += Vec3::new((p.y - q.y) * (p.z + q.z), (p.z - q.z) * (p.x + q.x), (p.x - q.x) * (p.y + q.y));
|
|
}
|
|
n * 0.5
|
|
}
|