# Wire within Tube - need equation

This topic is 4674 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Ok, imagine a wire that is represented by finite elements. Each of the elements is connected through bendable joints. If you give a spring constant to each joint you can represent the stiffness of the wire. So - if the wire would have a pre bent (preferred) shape (represented through an angle alpha0 at each joint) you could get the elasticity energy of the wire through calculating (alpha - alpha0)² * springConstant * 0.5 for each joint and summing up all the values. (Imagine it's a very simple - 2dimensional wire without torsion - alpha is the actual current degree at one of the joints) Ok. Now that wire is inserted into a tube. That tube can have it's own prebend shape and can have entirely different springConstants that the wire. What I want to know is - how can I determine the new shape of the combined objects. The wire can stretch the tube if the spring constants of the tube are less then the spring constants of the wire. It can also define the shape of the wire if it's constants are higher. Is there any close form to calculate the new alpha0s? If it soften's things up you can assume that the joints of both instruments are all aligned and have the same distance to each other.

##### Share on other sites
Hi Roga,

sounds like you're working on some interesting stuff. How does the SPH tie into this? Anyway, I suspect it is possible to get a closed form solution to this problem... but it would be an enormous amount of work, and I suspect that travelling down the numerical route would be better.

Tell me if I'm wrong, but I'm imagining you have this wire in the tube and you want to allow both to deform until that reach a minimal energy configuration. You said the wire is represented by finite elements, is the tube also represented in this way? Assuming things are nicely linear you might be able to get a solution using a Green's function approach. Still, I think that would be painful.

If I were approaching this problem I would probably use a relaxation method to allow the wire and tube to approach their steady state. If you do choose this approach watch out for multiple solutions.

##### Share on other sites
I'm is not sure what you want, but if you just want to get alpha0 and spring constants of combined thing, it's very easy.
With tube and wire in every joint have
torque=(wire_alpha0 - alpha)* wire_C + (tube_alpha0 - alpha) * tube_C

using very basic algebra you can open braces, rearrange, then factor (wire_C+tube_C) out and get

wire_and_tube_alpha0=(wire_alpha0*wire_C+tube_alpha0*tube_C)/(wire_C+tube_C)
wire_and_tube_C=wire_C+tube_C
so
torque=(wire_and_tube_alpha0-alpha)*wire_and_tube_C

(where C means spring constant).
Then if you want to get shape of relaxed thing, just bend by alpha0 in every point, obviously.

##### Share on other sites
Hey jjd,
thanks for your input. First - to answer your question: SPH doesnt really matter on this project ;-).

The wire in tube thing is a little bit different. I actually use an energy based approach and I solve an energy function but I want to solve the function for one object instead of two so I try to combine the two objects. I'll try to explain with a little drawing:

Imagine a wire that is completely straight and has a high "spring constant".

Wire:
|
|
|
|
|

Now there's the tube - it has a small spring constant and is bent in some way:

Tube:
/
/
/ (alpha0 at this joint = 0.5rad)
|
|

Now if I insert the wire into the tube the wire will straighten the tube depending on the relation of the spring constants

Wire in Tube:
/
|
/ (alpha0 at this joint = 0.2rad)
|
|

Now I guess that the relation is more complex than a simple

sC_all = sC_wire + sC_tube
alpha0 = alpha0_wire * sC_wire/sC_all + alpha0_tube * sC_tube/scAll;

But on the other hand I guess it can't be too complex - springs are quite linear models, aren't they? ;)

Greetings, Roga

##### Share on other sites
Ok, thanks Dmytry - that's the formular what I've been using so far but it's behaving very strange. I guess I gotta look into my code once more if there's another error.

##### Share on other sites
No, relation is no more complex, assuming tube and wire touch eachother everywhere, i.e. you don't have to deal with some collision detection and such.

If you want derivations, let
a is angle, w.a0 is wire's angle, t.a0 is tube's angle, w.c is wire's spring constant, t.c is tube's spring constant.

So we have : torque is equal to sum of torques:
torque=(w.a0-a)*w.c+(t.a0-a)*t.c;
open braces
torque=w.a0*w.c-a*w.c + t.a0*t.c-a*t.c;
reorder
torque=w.a0*w.c+t.a0*t.c - a*(w.c+t.c);
move (w.c+t.c) out
((w.a0*w.c+t.a0*t.c)/(w.c+t.c) - a)*(w.c+t.c)
so this equation is shown correct.

##### Share on other sites
Ok, I see - so my calculus was right from the beginning. Thanks for clearing that up...;-) Now - suggest you had to deal with the problem that the joints didn't have the same distance and they aren't aligned. How would you do that.

What I'm doing currently is - I integrate over the length of one joint (in the combined object) the values of the joints in the wire and in the tube (e.g adding all alpha0 and building a mean of the spring constants) and use these for calculation of alpha0. Does that seem correct to you too?

Thanks and greetings, Roga

##### Share on other sites
I was assuming that the wire was not attached to the tube in some way, are they coupled?

##### Share on other sites
Well, the wire is inside the tube - so there can only be one shape for both - right? (assuming the wire and the tube have roughly the same diameter). This object is inside another dynamic object that's much bigger so there you need complex energy equations.
But for the relaxed shape of the wire/tube combo simple math should suffice.

Greetings, Roga

##### Share on other sites
Can you make a "finer" or "coarser" approximation to your wire/tube with more/less joints by changing the response of each joint?

For a perfect simulation, you would want to have a near infinite number of such joints. Being able to change the number of joints used (and get approximetally the same results) would also mean that you could make both the wire and the tube have the same number of joints.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 13
• 9
• 9
• 34
• 16
• ### Forum Statistics

• Total Topics
634124
• Total Posts
3015661
×