Add design persistence, world rendering, metrics overlay and logs
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.
This commit is contained in:
parent
878d144b77
commit
190ef9cc4b
111 changed files with 14801 additions and 63 deletions
43
crates/materials/src/strength/tests.rs
Normal file
43
crates/materials/src/strength/tests.rs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
use fabrilis_core::units::Pascals;
|
||||
|
||||
use super::*;
|
||||
|
||||
fn steel() -> Strength {
|
||||
Strength {
|
||||
yield_strength: Pascals(250.0e6),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn factor_of_safety_is_yield_over_stress() {
|
||||
let factor = steel().factor_of_safety(Pascals(100.0e6)).unwrap();
|
||||
assert!((factor - 2.5).abs() < 1e-12);
|
||||
let factor = steel().factor_of_safety(Pascals(250.0e6)).unwrap();
|
||||
assert!((factor - 1.0).abs() < 1e-12);
|
||||
assert!(steel().factor_of_safety(Pascals(500.0e6)).unwrap() < 1.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn factor_of_safety_rejects_bad_stress() {
|
||||
assert!(steel().factor_of_safety(Pascals(0.0)).is_none());
|
||||
assert!(steel().factor_of_safety(Pascals(-1.0)).is_none());
|
||||
assert!(steel().factor_of_safety(Pascals(f64::NAN)).is_none());
|
||||
assert!(steel().factor_of_safety(Pascals(f64::INFINITY)).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn is_safe_compares_with_required_factor() {
|
||||
assert!(steel().is_safe(Pascals(100.0e6), 2.5));
|
||||
assert!(!steel().is_safe(Pascals(100.0e6), 2.6));
|
||||
assert!(steel().is_safe(Pascals(250.0e6), 1.0));
|
||||
assert!(!steel().is_safe(Pascals(250.0e6), 1.1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn is_safe_rejects_invalid_input() {
|
||||
assert!(!steel().is_safe(Pascals(0.0), 1.0));
|
||||
assert!(!steel().is_safe(Pascals(-10.0), 1.0));
|
||||
assert!(!steel().is_safe(Pascals(100.0e6), 0.0));
|
||||
assert!(!steel().is_safe(Pascals(100.0e6), -1.0));
|
||||
assert!(!steel().is_safe(Pascals(100.0e6), f64::NAN));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue