M3: STL/OBJ import with mesh validation, mass/COM/inertia, material database, RON scene with content-addressed blobs and v0->v1 migration. M4: deterministic heightmap terrain, trimesh colliders, wgpu renderer with instancing and depth, winit app with 1 kHz physics, fly camera, on-screen metrics overlay and per-frame CSV/dev logs. Docs: UI, logging, network and headless CLI plans.
50 lines
1.3 KiB
Rust
50 lines
1.3 KiB
Rust
//! A minimal static strength check at a single stress value.
|
|
//!
|
|
//! The load path and stress distribution are the caller's business; this module
|
|
//! only compares a stress with the material's yield strength.
|
|
|
|
use fabrilis_core::units::Pascals;
|
|
|
|
/// Yield data used for a static check.
|
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
|
pub struct Strength {
|
|
/// Yield strength of the material, Pa.
|
|
pub yield_strength: Pascals,
|
|
}
|
|
|
|
impl Strength {
|
|
/// Yield strength divided by the applied stress.
|
|
///
|
|
/// `None` for a non-positive or non-finite stress, and when the resulting
|
|
/// factor is not finite.
|
|
#[must_use]
|
|
pub fn factor_of_safety(self, stress: Pascals) -> Option<f64> {
|
|
let stress = stress.get();
|
|
if !stress.is_finite() || stress <= 0.0 {
|
|
return None;
|
|
}
|
|
let factor = self.yield_strength.get() / stress;
|
|
if factor.is_finite() {
|
|
Some(factor)
|
|
} else {
|
|
None
|
|
}
|
|
}
|
|
|
|
/// True when the factor of safety reaches `required`.
|
|
///
|
|
/// `required` must be finite and positive; any invalid input is unsafe.
|
|
#[must_use]
|
|
pub fn is_safe(self, stress: Pascals, required: f64) -> bool {
|
|
if !required.is_finite() || required <= 0.0 {
|
|
return false;
|
|
}
|
|
match self.factor_of_safety(stress) {
|
|
Some(factor) => factor >= required,
|
|
None => false,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests;
|