Gin
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Catenary Class Reference

Calculates the curve of a hanging cable (catenary). More...

#include <gin_catenary.h>

Public Member Functions

 Catenary (float x0, float y0, float x1, float y1, float addLength, int numIterations=1)
 Creates a catenary curve between two points.
 
void calculate (float x0, float y0, float x1, float y1, float addLength, int numIterations=1)
 Calculates or recalculates the catenary curve between two points.
 
float calcY (float x) const
 Calculates the y coordinate for a given x position on the catenary curve.
 
std::pair< float, floatgetVertex () const
 Returns the vertex (lowest point) of the catenary curve.
 

Detailed Description

Calculates the curve of a hanging cable (catenary).

A catenary is the natural curve formed by a cable, rope, or chain hanging between two points under its own weight. This class calculates the mathematical catenary curve and provides methods to query points along it.

Common uses:

The curve is defined by two endpoints and the additional length of cable beyond the straight-line distance between the points.

See also
calculate, calcY, getVertex

Constructor & Destructor Documentation

◆ Catenary()

Catenary::Catenary ( float  x0,
float  y0,
float  x1,
float  y1,
float  addLength,
int  numIterations = 1 
)

Creates a catenary curve between two points.

Parameters
x0X coordinate of the first endpoint
y0Y coordinate of the first endpoint
x1X coordinate of the second endpoint
y1Y coordinate of the second endpoint
addLengthAdditional cable length beyond the straight-line distance
numIterationsNumber of Newton-Raphson iterations for precision (default: 1)

References calculate().

Member Function Documentation

◆ calculate()

void Catenary::calculate ( float  x0,
float  y0,
float  x1,
float  y1,
float  addLength,
int  numIterations = 1 
)

Calculates or recalculates the catenary curve between two points.

The addLength parameter determines how much "slack" the cable has. A value of 0 would be a straight line (impossible for a real cable). Larger values create more pronounced sag.

Parameters
x0X coordinate of the first endpoint
y0Y coordinate of the first endpoint
x1X coordinate of the second endpoint
y1Y coordinate of the second endpoint
addLengthAdditional cable length beyond the straight-line distance (must be > 0)
numIterationsNumber of Newton-Raphson iterations for precision (default: 1)

Referenced by Catenary().

◆ calcY()

float Catenary::calcY ( float  x) const

Calculates the y coordinate for a given x position on the catenary curve.

Use this to sample points along the curve for drawing.

Parameters
xThe x coordinate
Returns
The y coordinate at that x position

◆ getVertex()

std::pair< float, float > Catenary::getVertex ( ) const

Returns the vertex (lowest point) of the catenary curve.

Returns
A pair containing (x, y) coordinates of the vertex

The documentation for this class was generated from the following file: