Code to calculate Catenary curves?
-
Could be quite tricky, although my understanding of catenary curves is pretty vague.
Im off for a few hours, so i'll think about it a bit and get back to you.
-
Thanks remus. I've found myself on deep water with this problem. Been a while since I've done any math beyond simple + - * /, but I've never done this kind of math.
(I can hear all my former math teachers laughing, quoting me "I'll never have any use of that in real life!" sigh )
-
Looking at: http://mathworld.wolfram.com/Catenary.html
@unknownuser said:
The arc length, curvature, and tangential angle for t>0 are given by
Is the first one the arch length?
-
Indeed i think the first one is arc length.
i've found another form that might be a bit more useful:
arc length = (2H/w)* sinh (wl/2H)
where H=horizontal tension on the cord, w=weight of the cord and and l=distance between the 2 points.
thinks a bit more
-
I've been searching some more on Catenary and it appears that the formulas assume the two points to be at equal height.
The example at wolfram site has code which generates a curve from points at different heights. http://demonstrations.wolfram.com/CatenaryTheHangingChain/
But I can't interpret the code. And it also appears to not be a variable width arc.The thing is, it's not required that I use the Catenary equation. It's just what seemed to be to be related to what I wanted to do. If anyone got other suggestions, I'm all ears.
-
Ok, i think i've sort of got it.
Essentially the problem boils down to finding the correct value of
a
for your length of rope and the distance between the 2 fixing points.This is given by
a=w/H
wherew
=weight of the rope andH
=horizontal force tensioning the rope. If you have got some accurate values for w and H you should be able to work out a and then substitute it back in to the original catenary equation (y=a*cosh(x/a)
)Thats the easy version, if you cant make that work i think it gets yet more complicated, as i dont think you can get a value for
a
easily only knowingL
.It should also be possible to make it work with points at unequal heights, although again it would add an extra level of complication.
p.s. the parabola is a reasonable approximation to a catenary curve, and could simplify the maths quite a bit. Probably worth having a look in to it if you dont need to be entirely accurate.
-
@remus said:
p.s. the parabola is a reasonable approximation to a catenary curve, and could simplify the maths quite a bit. Probably worth having a look in to it if you dont need to be entirely accurate.
Good point. I think that's worth investigating. I don't want to do a true physic simulation. Just something that closely looks like ropes.
The whole idea comes from last week when I modelled an old boat crane located on the site for a project at work. It has lots of wires hanging about. I had it rigged, but at some point I wanted to adjust it's arm positions, which resulted in me having to re-rig all the wires. So I thought I'd try to make a plugin which allowed you to pick to vertices in the model, specify a length and it'd make the rope. As you move/rotate the objects the rope/cable/wire is attached to they'll deform accordingly. That an making a plugin to allow me to set up pivot points which I can control from a webdialog so I get a control panel for the crane, or whatever you set up.)
Ok, parabola...
-
Having heard a bit more about your idea, are you absolutely sure you want to do it by specifying the length? i'm fairly sure you could do it by specifying the value of a.
-
How would that work? I'd still like it to hang more when the points are closer together. Would it do that?
Came across this: http://mathforum.org/library/drmath/view/53706.html looks interesting. Though, it's getting late now. Need to get some sleep. This stuff bends my brain.
-
Found two more resources about and unequal heights.
http://home.earthlink.net/~w6rmk/math/catenary.htm <- got an approximation, might be useful
http://members.chello.nl/j.beentjes3/Ruud/catfiles/catenary.pdf <- got some sample C code, but it seem to solve it by doing trial and error...now, seriously, sleep.
Again, thank you very much Remus for your input.
-
You would have to set a value of a for each curve, but then youd also have to set a length for each curve as well, so id imagine it'd work out pretty similar in terms of the amount of effort on the part of the user. I suppose you could also set the value for a relative to the distance between the 2 points, which should give you quite a similar effect to setting a length but without all the hard work.
As for the problem of unequal heights, from the links you provided it would seem an iterative method is necessary, although i'll look in to it a bit more.
If i remember i'll ask my maths tutor at college about it. Might know a good way of doing it.
-
Check out this port, this might help you.
http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=64842
All the best Marco
-
Hi,
Check this one by Aerilius: http://rhin.crai.archi.fr/rld/plugin_details.php?id=990
Advertisement