Obi Official Forum
Rest length show incoherent value - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html)
+--- Thread: Rest length show incoherent value (/thread-3650.html)



Rest length show incoherent value - lufydad - 17-11-2022

Hi,

I made a scene with a rope that is pulled on both sides. At the start its size is 4.28 m and later when attachments pulled it we see in unity a size of approximatly 15 m but rest length still show 4.28 m (see https://imgur.com/a/9YfSQc6).
Is there something that I don't understand with rest length ? I based my thought on Changing rope length at runtime: ObiRopeCursor : "It is very useful to know the current length of the rope when working with cursors. Use the rope's RestLength property for this.".

Thanks in advance,


RE: Rest length show incoherent value - josemendez - 17-11-2022

(17-11-2022, 11:24 AM)lufydad Wrote: Hi,

I made a scene with a rope that is pulled on both sides. At the start its size is 4.28 m and later when attachments pulled it we see in unity a size of approximatly 15 m but rest length still show 4.28 m (see https://imgur.com/a/9YfSQc6).
Is there something that I don't understand with rest length ? I based my thought on Changing rope length at runtime: ObiRopeCursor : "It is very useful to know the current length of the rope when working with cursors. Use the rope's RestLength property for this.".

Thanks in advance,

Hi!

The rest length is -as the name implies- the length of the rope at rest: this is, when it isn't stretched nor compressed. You can stretch a 4.28 meters long rope until it reaches 15 meters, but that doesn't change the fact that the amount of rope in there is still 4.28 meters, and will return to 4.28 once the stress forces cease to act upon it: no matter is created/destroyed in the process Guiño.

The actual length can be completely different from the rest length depending on how much the rope is stretched or compressed. The rest length is determined when you create the rope blueprint, while the "actual" length must be recalculated at runtime since it can change. To calculate the current length of the rope, use rope.CalculateLength().

There's something useful you can do with both rest length and the actual length, and that's to calculate strain: a measure of how much stretch/compression the rope is undergoing. This is just the ratio between both values:

Code:
float strain =  rope.CalculateLength() / rope.restLength;

strain will be > 1 if the rope is stretched, < 1 if it's compressed, and 1 if there's no stress forces acting upon it.

Quote:I based my thought on Changing rope length at runtime: ObiRopeCursor : "It is very useful to know the current length of the rope when working with cursors. Use the rope's RestLength property for this.".

Knowing the rest length is useful when dealing with cursors because they set the rest length of the rope: they "add" or "remove" matter to/from the rope, so to speak. The rope may very well be stretched under a lot tension while this happens, or may not be at all.

let me know if you need any help,

kind regards


RE: Rest length show incoherent value - lufydad - 17-11-2022

(17-11-2022, 12:04 PM)josemendez Wrote: Hi!

The rest length is -as the name implies- the length of the rope at rest: this is, when it isn't stretched nor compressed. You can stretch a 4.28 meters long rope until it reaches 15 meters, but that doesn't change the fact that the amount of rope in there is still 4.28 meters, and will return to 4.28 once the stress forces cease to act upon it: no matter is created/destroyed in the process Guiño.

The actual length can be completely different from the rest length depending on how much the rope is stretched or compressed. The rest length is determined when you create the rope blueprint, while the "actual" length must be recalculated at runtime since it can change. To calculate the current length of the rope, use rope.CalculateLength().

There's something useful you can do with both rest length and the actual length, and that's to calculate strain: a measure of how much stretch/compression the rope is undergoing. This is just the ratio between both values:

Code:
float strain =  rope.CalculateLength() / rope.restLength;

strain will be > 1 if the rope is stretched, < 1 if it's compressed, and 1 if there's no stress forces acting upon it.


Knowing the rest length is useful when dealing with cursors because they set the rest length of the rope: they "add" or "remove" matter to/from the rope, so to speak. The rope may very well be stretched under a lot tension while this happens, or may not be at all.

let me know if you need any help,

kind regards

Ok the name wasn't clear for me, because when we add/remove particles it changes the "rest" length. But it's more clear now with your answer, thank you a lot !

If I want to clamp the length of the rope to its rest length, do you think it could be a great idea to for example reduce its length when strain is above 1 ?


RE: Rest length show incoherent value - josemendez - 17-11-2022

(17-11-2022, 12:37 PM)lufydad Wrote: If I want to clamp the length of the rope to its rest length, do you think it could be a great idea to for example reduce its length when strain is above 1 ?

Hi!

That's not a good idea, because the rope will permanently shrink once you stop pulling it. What you want is to simply reduce stretching.

You can do this by making sure the solver is able to withstand the stress forces and solve the system within the time budget given. This can be accomplished by:

A) - Reducing the mass ratio between the rope and the objects attached to it: intuitively speaking, if an object is hanging from a rope and you reduce the mass of the object (making it lighter) or increase the mass of the rope (making it heavier) the rope will stretch less.

Very heavy objects interacting with very light objects make for physics interactions that are harder to solve, so physics solvers need to spend more time to get an accurate solution. This is common to all existing physics engines.

B) - Reducing rope resolution, so that it uses less particles. This makes the simulation simpler and allows the solver to solve for larger mass ratios.

C) - Increasing the solver's budget, to allow it to solve more complex problems involving objects of wildly different masses. Simplest way to do this is to update the solver more often by spending more substeps in the simulation (you can find this setting in ObiFixedUpdater component). The manual has an in-depth explanation about how iterations/substeps affect the outcome, see:
http://obi.virtualmethodstudio.com/manual/6.3/convergence.html

kind regards,