A little anchoring javascript fun.

GHA

Well-Known Member
Joined
26 Jun 2013
Messages
12,552
Location
Hopefully somewhere warm
Visit site
This is very much me just playing around to see what javascript /Raphael graphics library can do, but I thought it might be worth sharing.

The black rectangle is a boat, drag it around, the straight line should be a catenary in real life.

http://www.moondogmoving.co.uk/js/testcat.html?

The force at the top should be the force required to just lift all the chain off the seabed, other bits hopefully self explanatory.

Calculated by force =chainweight (kg per metre) X chain length squared / 2 x depth

Look right to anyone who actually does know what they're talking about :)

Lots more buttons and a grid might help, but on just a tablet with no keyboard it's a bit slow...

Bit reluctant to share the code as it's such a mess....
Oh why not :)


Code:
<!doctype html>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>horizontal force </title>    
    <script type="text/javascript" src="raphael-min.js"></script> 
    
    
  </head>
  <body>
  
    <div id="my-canvas" class="canvas"></div>
    
    <form name="example">
<input type="radio" name="test">
</form>


    <script type="text/javascript">
        Raphael('my-canvas', 800, 400, function() {
            var paper = this;
             var border= paper.rect(0,100,800,300);
            var square = paper.rect(300, 200, 100, 30).attr('fill', '#000');
            square.data('chain_length', 50);
            square.data('chain_weight', 2);
            square.data('water_depth',10);
            
           
           var    force=square.data('chain_weight') *square.data('chain_length') * square.data('chain_length') /(2*square.data('water_depth') );    
             var text_length = paper.text(100,55,'length of chain=' + square.data('chain_length')+'m');
            var text_force= paper.text(100,10,force +'Kg');
            var text_depth= paper.text(100,30,'Depth of water ='+square.data('water_depth'));
            var chain= paper.path();
            var text_weight= paper.text(200,30,'chainweight='+square.data('chain_weight'));
            var scope
            
           
            update();
            
            function update(){
            force=(square.data('chain_weight') *square.data('chain_length') * square.data('chain_length')) /(2*square.data('water_depth') );    
            text_length.remove();
            
            scope=Math.round(square.data('chain_length')/square.data('water_depth')*10)/10;
             text_length = paper.text(100,55,'length of chain=' + square.data('chain_length')+'m'+'    1:'+ scope);
             text_force.remove();
             text_force= paper.text(100,10,'Force ='+Math.round(force) +'Kg');
             text_depth.remove();
             text_depth= paper.text(100,30,'Depth of water ='+square.data('water_depth'));
             text_weight.remove();
             text_weight= paper.text(200,30,'chainweight='+square.data('chain_weight'));
             
             
             //document.example.test 
           } 
            
            
            var startX, startY;
        
            
            
            
            
            
            


            function onstart() {
                startX = this.attr('x');
                startY = this.attr('y');


                this.attr('fill', 'pink'); }


            function onend() {
                this.attr('fill', '#000');
                
                chain.animate({ 
                    path: [ 
                    'M', 0, 400, 
                    'L', xx, yy
                    ] 
                    }, 500,  'bounce');
                    
                    update ();
               //     input.force
           //    square.data('chain_length', 6); 
                 
              
               
                }
                 
            function onmove(dx, dy) {
              if (startX + dx <700  && startX +dx >=0 && startY +dy >99 && startY + dy <385) 
     {
                this.attr({
                    x: startX + dx,
                    y: startY + dy}); 
                     
                    square.data('chain_length', Math.round(Math.sqrt((startX+dx)*(startX+dx)+(400-(startY+dy+15) )*(400-(startY+dy+15) )) /10)) ;     
                    square.data('water_depth',  (400-(startY + dy+15) ) /10);
                    
                     xx= startX + dx
                    yy=startY + dy+15
                    
                   
            
      //    update();
            }
           } 
           
            square.drag(onmove, onstart, onend);
        });
        
        
        
        
        
        
    </script>
    
    
    
    
  </body>
</html>
 
Last edited:
Force measured in kg?

In air that would be x 9.8 (or 10) to give the force for gravity... so in otherwords if it says you need 10kg you could rig a pulley and hang 11kg on the otehr side of the block and it would lift the 10kg object.

BUT while not huge would a chain have any buoyancy? So would it be possible to do the same with the chain and a pulley but hang 9kg and it lift it?

Is there some way to estimate the tidal and wind forces on the boat to know what it will pull at...
 
Can't run it but suggest you look @ http://alain.fraysse.free.fr/sail/rode/anchor/anchor.htm

He did a spreadsheet with some simple macros which allowed you to choose boat length (windage), bottom type, rode length, rode type, and wind force to come up with loads in SIS.
Can't find it now, but do have a copy on 3 computers (he did the work in 2005).
Know that site very well, ta :)

Wonder why it won't run - what browser are you using?
 
Force measured in kg?

In air that would be x 9.8 (or 10) to give the force for gravity... so in otherwords if it says you need 10kg you could rig a pulley and hang 11kg on the otehr side of the block and it would lift the 10kg object.

BUT while not huge would a chain have any buoyancy? So would it be possible to do the same with the chain and a pulley but hang 9kg and it lift it?

Is there some way to estimate the tidal and wind forces on the boat to know what it will pull at...
Sorry, not very clear, the force is the horizontal force only, the force pulling the anchor . Also, the chain weight has been downed a little already from 2.2kg/M (10mm) to 2kg/M, roughly 90%
 
The force seems to come out higher than I would have expected. I have set the rectangle at 4.5 metre depth, 33 metres of chain, which would be a pretty typical situation for us. That produces a force of 242 kg. I have witnessed all my chain lifting off the bottom in around force 6-7 using those measurements but my 12 mm nylon snubber was stretching only a little. The ABYC SWL for 1/2" nylon three-strand is 320 kg and I doubt that I was anywhere near that.
 
The force seems to come out higher than I would have expected. I have set the rectangle at 4.5 metre depth, 33 metres of chain, which would be a pretty typical situation for us. That produces a force of 242 kg. I have witnessed all my chain lifting off the bottom in around force 6-7 using those measurements but my 12 mm nylon snubber was stretching only a little. The ABYC SWL for 1/2" nylon three-strand is 320 kg and I doubt that I was anywhere near that.
Seems fairly close according to this site...

http://www.spaceagecontrol.com/calccabm.htm?F=2370&a=63&q=2&g=9.81&Submit+Button=Calculate

I'm just taking a formula taken off the web which I think an approximation which works well as long as the scope doesn't get too small.
 
This was done a while ago and I just noticed the chain length isn't, it's the straight line distance from the box to the anchor, not the catenary length....... Need to start from scratch really.
 
Seems fairly close according to this site...

http://www.spaceagecontrol.com/calccabm.htm?F=2370&a=63&q=2&g=9.81&Submit+Button=Calculate

I'm just taking a formula taken off the web which I think an approximation which works well as long as the scope doesn't get too small.

It so happens that I have recently bought just over 240 kg of lead for ballast. It is very heavy! I would like to think that my snubber, deck cleats and anchor will take that much but I have serious doubts. Not quite sure what your site is telling me about anchoring, as the difference between straight line and catenary lengths would seem to be insignificant.
 
The force seems to come out higher than I would have expected. I have set the rectangle at 4.5 metre depth, 33 metres of chain, which would be a pretty typical situation for us. That produces a force of 242 kg. I have witnessed all my chain lifting off the bottom in around force 6-7 using those measurements but my 12 mm nylon snubber was stretching only a little. The ABYC SWL for 1/2" nylon three-strand is 320 kg and I doubt that I was anywhere near that.

Yes, but am I not correct in thinking that your chain is only 8mm?
 
Yes, but am I not correct in thinking that your chain is only 8mm?
Hope so :) I can't see where it's gone wrong otherwise. 8mm chain ages it down to 157kg, less than 2 blokes.

http://moondogmoving.co.uk/js/testcat8mm.html?

The straight line vs catenary length turned out to be a bit of a red herring as the calc does it from the numbers, but the visual looks wrong. Which it does anyway :)
 
Hard to grab and move the sliders on this 7" tablet. I can't move the rectangle - am I meant to be able to?
 
Top