# 2D Collisions engine

I am working on a fabric simulator at low level, I have done some work and at this point there are some points where I would appreciate help.

The input of the program is a DRF file. This is a format used in sewing machines to indicate the needles where to move.

The 2D representation is accurate, I parse the DRF info to a polyline, apply tensions and I extrude this in a openGL render.

Now I am trying to achieve the 3D ZAxis physics. I tried two methods:

1) Asuming information

First method is based on constrains about the process of manufacturing: we only take care of the knots where a set of yarns interact and comupte z separation in this crucial points. The result is regular: good in a lot of cases but with a lot of botched jobs in order to avoid causistincs where this is not a good assumtion (for example, doing beziers, collisions in zones between this crucial points). We desist on this alternative when we saw there was a lot os causistic we would have to hardcode,probably creating aditional gliche.

2) Custom 2D Engine

The second attempt is to aprox the yarns with box colliders 2D, check collisions with a grid, and compute new Z in funcion of this. This is by far more expensive, but leads to a better results. Although, there is some problems:

• The accuracy of box colliders over the yarn is not absolute ( there are ways to solve this but it would be great to read some alternatives)
• There is not iterative process:

First we compute collisions pairwise, and add to each collider a list of colliding colliders. Then, we arrange this list and separate the Z axis in function of yarn's radius with center 0.The last step is to smooth the results from discrete z to a beziers or smoothing filters. This leads to another glitches. If I extend this recomputation to all the collisions of the current collisions, I get weird results because z changes are bad propagated( maybe I am not doing good this point)

• Some colliders are recomputed wrong ( first computed yarns have more posibilites to be altered for the last ones, leading on gliches)

some of the glicthes (mainly in the first yarns computed:

At this point I have some questions:

• Can I fix this glitches (or a great part at least)? Glitches about bad aproximation and glitches for z recomputation
• A 3D engine like ODE could do the job in a reasonable time?

If you need some specific code don't hestiate on ask for it.

Thanks a lot!

• I don't understand your images. Why are they bad? What are the glitches? – Trilarion Sep 15 '17 at 10:36
• You can see the pink yarn crossing the yellow one at multiple points! – Charles Sep 15 '17 at 11:17
• Okay, I see that now. In which area is the problem? Maybe the input data is just too bad (low spatial-temporal resolution or wrong values)? – Trilarion Sep 15 '17 at 11:43
• The input data does not have Z axis, is 2D. I am trying to generate this Z data by mean a collision system. the problem is that once I compute collisions I have to smooth the yarns, and I am not able to achieve this without mess the whole thing. – Charles Sep 15 '17 at 11:47
• You might want too much. If z axis information is missing you don't know in which z-order the different yarns were. You can only guess. You might guess wrong. What then? Probably yarn coiling around each other is not good, I could imagine. But apart from this? Should the yellow yarn be above or behind the pink in the examples? Also, why is smoothing necessary? Maybe too much smoothing does not reproduce the z-order of the yarn intact. So maybe locally adaptive smoothing. – Trilarion Sep 15 '17 at 11:52