/// <summary> /// Calculates the horizontal tension needed to achieve specified curve length /// </summary> /// <param name="span">The span</param> /// <param name="w">The unit weight</param> /// <param name="L">The specified length</param> /// <param name="tol">The tension tolerance for numeric solution (default 0.001)</param> /// <returns>The horizontal tension value</returns> public static double SetTotalLength(Vector2 span, double w, double L, double tol) { if (tol <= 0) { tol = 1e-6; } L = Math.Max(L, MinExtension + span.Manitude); double H_init = L > span.Manitude?w * Math.Sqrt(DoubleEx.Cub(span.Manitude) / (24 * (L - span.Manitude))):100000; Func <double, double> f = (H_) => TotalLength(span, w, H_); if (f.Bisection(L, H_init, tol, out double H)) { return(H); } return(H_init); }