# Basic pseudocode to create a rope physics

I am trying to simulate the physics of a 2D hanging rope, consistent of a series of n-links. It could be a series of four pendulums. I just want some movement of the rope and the ability to contact with the ground. I was inspired by this question and this one.

I would like to programme it from zero in Python or a similar modelling program, but I don't find simple maths to recreate this effects. Which are the basic equations to escalate a series of n-links to resemble like a rope, please?

• It looks like that first link already has working code you can translate, and the second has some explanation of the thinking behind these rope models. Where have you run into difficulty adapting these answers to your Python solution? Mar 19 '20 at 11:24
• probably, i'm not very skillful at coding and I'm more used to sinthetic math equations which then I can translate to Python or similar programming languages. Mar 19 '20 at 11:34
• Here is another detailed answer regarding how to implement 2d verlet chain type physics: stackoverflow.com/a/42618200/12145926 Mar 19 '20 at 18:30

## 2 Answers

The article linked below provides good starting pseudocode. With images and video. I actually used it to create fishing rope in my previous game too.

Simulate Tearable Cloth and Ragdolls With Simple Verlet Integration

• Rope is just 1D of cloth simulation.
• ability to contact with the ground To make it able to react with game world you need link it with game collision code. In your case Python, I dont know which will you use. But for my case Unity, I put tiny SphereCollider on each rope node and it can now rest on ground.

2D rope physics in pseudocode with explanations: http://web.archive.org/web/20160418004153/http://freespace.virgin.net/hugo.elias/models/m_string.htm

Other models explained by Hugo Elias: http://web.archive.org/web/20160418004148/http://freespace.virgin.net/hugo.elias/models/m_main.htm