8 unstable releases (3 breaking)
new 0.4.1 | Apr 8, 2025 |
---|---|
0.4.0 | Mar 31, 2025 |
0.3.0 | Mar 29, 2025 |
0.2.0 | Mar 28, 2025 |
0.1.1 | Feb 21, 2025 |
#14 in #curve
689 downloads per month
Used in plotpoint
63KB
1K
SLoC
Catenary
Catenary is a Rust library for calculating catenary curves. It provides tools to model the shape of a hanging flexible chain or cable under its own weight.
Features
- Calculate catenary curves from given parameters
- Easy to integrate with other Rust projects
Installation
Add this to your Cargo.toml
:
[dependencies]
catenary = "0.1.0"
Generate coefficient table
In order to quickly find catenary, with 2 points and a length, we can interpolate between catenaries that have been saved into a table. To regenerate this table, do:
cargo run --bin generate_table -- --help
Getting the desired catenary by interpolation from the table is done with this function:
let cat = table.get_catenary::<f64>(&p0, &p1, &l).unwrap();
Or just download them
let path = get_dataset_path().await.unwrap();
Usage
Here is a simple example of how to use Catenary:
extern crate catenary;
use catenary::Catenary;
fn main() {
let catenary = Catenary::new(1.1, 2.2, 3.3, -4.4, 5.5);
let (p0, p1) = catenary.end_points();
let solved = Catenary64::from_points_length(&p0, &p1, catenary.length()).unwrap();
assert_relative_eq!(catenary.a, solved.a, epsilon = 1e-5);
assert_relative_eq!(catenary.c, solved.c, epsilon = 1e-5);
assert_relative_eq!(catenary.h, solved.h, epsilon = 1e-5);
}
License
This project is licensed under the MIT or Apache-2.0 Licenses.
Contribution
Contributions are welcome! Please open an issue or submit a pull request on GitLab.
Dependencies
~13–26MB
~385K SLoC