trussx
Utilities for building and analysing pin-jointed truss structures. The crate provides a small, strongly-typed API for creating joints and members, applying loads and supports, and running a linear elastic analysis in three dimensions.
Installation
Add the dependency to your Cargo.toml:
[]
= "0.2"
Usage
use ;
Both the cross-sectional area and elastic modulus must be strictly positive. The library
rejects zero or negative inputs with a descriptive
TrussEditError so incorrect
data is surfaced before attempting an analysis.
Testing
The project includes unit tests that validate the analysis results for a simple bar in tension and ensure meaningful error reporting when required data is missing. Run the full suite with:
Member safety factors
Assign a yield strength to each member with set_member_yield_strength to enable factor of
safety calculations. During Truss::evaluate the library compares the absolute yield
strength to the absolute axial stress for each analysed member and stores the ratio. You can
read the value back with member_factor_of_safety.
member_factor_of_safety returns None when:
- No yield strength has been assigned to the member.
- The structure has not been analysed since the last modification.
- The computed axial stress is effectively zero (no meaningful demand).
- The resulting ratio is not a finite floating-point number.
The repository includes an executable example that demonstrates the workflow end-to-end:
See examples/factor_of_safety.rs for the full
source. The integration tests under tests/ mirror the same
cantilever scenario to provide executable documentation for the API without
requiring a standalone CLI.