Crate catenary

Source
Expand description

This module provides functionality for working with catenary curves.

A catenary curve is defined by the equation: y(x) = a * cosh((x - c) / a) - a + h where:

  • a is the parameter that controls the shape of the curve.
  • c is the horizontal shift of the curve.
  • h is the vertical shift of the curve.
  • s_0 and s_1 are the arc lengths of the end points (negative on the left of the minimum, positive on the right).

The module includes the following functionality:

  • Representation of a catenary curve with the Catenary structure.
  • Methods for creating and manipulating catenary curves.
  • Methods for computing various properties of catenary curves, such as the y-coordinate from a given x-coordinate, the x-coordinate from a given y-coordinate, the length of the curve, and the end points of the curve.
  • Methods for creating a catenary curve from two points and a specified length, with or without an initial guess.
  • Methods for creating a catenary curve from a line segment.
  • Implementation of the LeastSquaresProblem trait for solving catenary curve fitting problems using the Levenberg-Marquardt algorithm.

The module also includes a sub-module for generating a table of catenaries (table) and a sub-module for working with roots (roots).

§Examples

use catenary::{CatMaker, Catenary64};
use nalgebra::Point2;
use approx::assert_relative_eq;

let catenary = CatMaker::a(1.1).c(2.2).h(3.3).s_0(-4.4).s_1(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);

Re-exports§

pub use catenary::catmaker::CatMaker;
pub use catenary::Catenary;
pub use catenary::Catenary32;
pub use catenary::Catenary64;
pub use table::Table;
pub use table::Table32;
pub use table::Table64;

Modules§

catenary
Module for working with catenary curves.
roots
Module for working with roots.
table
Module for generating a table of catenaries, so we can easily interpolate between them. A table of catenaries, used to interpolate between them, so we don’t have to solve the catenary equation every time.