Author Topic: Draw a Catenary Curve ?  (Read 4198 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Draw a Catenary Curve ?
« on: July 21, 2020, 12:32:20 pm »
How do you draw a Cantenary Curve

From pt A to pt B and say the curve length is k * the distance between A and B, say k = 1.25 ie 1.25 * _HYPOT(ax-bx, ay-by) = the length of the curve (a rope or chain hanging from pole A and pole B).

They say the formula for y = a * cosh(x/a) = a/2*(exp^(x/a) + exp^(-x/a))  << EDIT

a is lowest point when x = 0 but how does that help our drawing of the situation?
« Last Edit: July 21, 2020, 01:49:20 pm by bplus »

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Draw a Catenary Curve ?
« Reply #1 on: July 21, 2020, 01:09:31 pm »
According to Wikipedia, the relationship between curve length, horizontal separation, vertical separation and the catenary parameter "a" is

"a transcendental equation in "a" and must be solved numerically"

Haven't the faintest idea what a "transcendental equation" is, but "must be solved numerically" doesn't sound hopeful.  Good luck!  We await the mathematicians amongst us.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Draw a Catenary Curve ?
« Reply #2 on: July 21, 2020, 02:07:40 pm »
OK here is a thought experiment:

I have a line hanging from two poles of same height. I move toward middle of 2 poles grab the line and cut the line.

Will the curve of the line remaining change shape?

I am thinking no, unless the tension in the line is changed. I could install a pole with eye hook at same height and attach line to it and it would not change shape.


Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: Draw a Catenary Curve ?
« Reply #3 on: July 21, 2020, 03:04:28 pm »

I really had to google for how it was, but it worked.

Code: QB64: [Select]
  1. ab_dis = 350 'a-b distance in horizontal axis
  2. b_max = 260 'the rope length (proportional to weight)
  3.  
  4. see = _NEWIMAGE(500, 500, 32): SCREEN see: y_points = 80
  5.  
  6. a_x1 = 30
  7. a_x2 = a_x1 + ab_dis
  8.  
  9.  
  10. a_y = 50 'vertical axis of points
  11.  
  12. CIRCLE (a_x1, a_y), 20
  13. CIRCLE (a_x2, a_y), 20
  14.  
  15. FOR act_x = 0 TO ab_dis
  16.  
  17.     b = (1 - ((ab_dis - 2 * act_x) / ab_dis) ^ 2) * -b_max
  18.     PSET (act_x + a_x1, a_y - b)
  19.  
  20. NEXT act_x
  21.  
  22.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Draw a Catenary Curve ?
« Reply #4 on: July 21, 2020, 04:35:54 pm »
Well that is definitely interesting, thank you @MasterGy

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Draw a Catenary Curve ?
« Reply #5 on: July 22, 2020, 01:21:20 pm »
RE: MasterGy's interesting formulation

Since I see a Squared expression a possible quadratic and 0 expressions with EXP or cosh, I strongly suspect this curve is parabolic and not catenary, easy to mistake the 2 as even Galileo hypothesized a parabolic equation for the same situation. And it might just do for my intended use.

I was hoping for code to handle different heights of the 2 ends. If parabolic, I know we could chop the ends on either side anywhere we want without effecting the shape of the curve but it might be different for catenary curve.
« Last Edit: July 22, 2020, 01:27:42 pm by bplus »

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: Draw a Catenary Curve ?
« Reply #6 on: July 22, 2020, 02:47:13 pm »
A different vertical conception can be easily incorporated if it is assumed that the center of gravity will fall to the center.

Code: QB64: [Select]
  1. ab_dis = 350 'a-b distance in horizontal axis
  2. b_max = 260 'the rope length (proportional to weight)
  3.  
  4. see = _NEWIMAGE(500, 500, 32): SCREEN see
  5.  
  6. a_x1 = _WIDTH(see) / 2 - ab_dis / 2 'position to horizont central
  7. a_x2 = a_x1 + ab_dis
  8.  
  9. a_y1 = 50 'A-vertical axis of points
  10. a_y2 = 120 'B-vertical axis of points
  11.  
  12. CIRCLE (a_x1, a_y1), 20
  13. CIRCLE (a_x2, a_y2), 20
  14.  
  15. FOR act_x = 0 TO ab_dis
  16.  
  17.     b = (1 - ((ab_dis - 2 * act_x) / ab_dis) ^ 2) * b_max
  18.     b = (a_y2 - a_y1) / ab_dis * act_x + b
  19.  
  20.     PSET (act_x + a_x1, a_y1 + b)
  21.  
  22. NEXT act_x
  23.  
  24.  

I found this on google and I rather miss it that the weight is proportional to the length of the rope. I don’t like it so much, it would be nice if the length of the rope and the weight could be given separately, because sometimes, if the rope is short and the weight is big, you would have to take a regular “V” shape. This method is not suitable for this :(.
« Last Edit: July 22, 2020, 02:49:41 pm by MasterGy »