axiolid_primitive/half_space.rs
1//! Unbounded half-space representation and explicit mesh clipping policy.
2
3use axiolid_core::{Plane3, Scalar};
4
5/// One side of an infinite plane.
6#[derive(Debug, Clone, Copy, PartialEq)]
7pub struct HalfSpace {
8 /// Boundary plane.
9 pub boundary: Plane3,
10 /// `true` selects the normal side, `false` the opposite side.
11 pub agreement: bool,
12}
13
14/// Relative amount by which a subject bound is expanded before an unbounded
15/// half-space participates in a finite mesh operation.
16#[derive(Debug, Clone, Copy, PartialEq)]
17pub struct ClipMargin(Scalar);
18
19impl ClipMargin {
20 /// Construct a positive relative margin.
21 pub fn new(factor: Scalar) -> Option<Self> {
22 (factor.is_finite() && factor > 0.0).then_some(Self(factor))
23 }
24
25 /// Relative factor.
26 pub const fn factor(self) -> Scalar {
27 self.0
28 }
29}