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 linear abscissas 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 grid of catenaries (grid) and a sub-module for working with roots (roots).

§Examples

use nail::catenary::Catenary;
use nalgebra::Point2;
use approx::assert_relative_eq;

let catenary = Catenary::new(1.1, 2.2, 3.3, -4.4, 5.5);
let (p0, p1) = catenary.end_points();
let solved = Catenary::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);

Modules§

grid
Module for generating a grid of catenaries, so we can easily interpolate between them.
roots
Module for working with roots.

Structs§

Catenary
Represents a Catenary curve.