Amin Ghafari


Contact details:
Computer Mechanics Laboratory
Etcehverry Hall
UC Berkeley, 94720 CA
Email: amin[dot]ghafari[at]berkeley[dot]edu
  • GitHub: Amin Ghafari
  • Linkedin: Amin Ghafari
  • Cloth Simulator

    Amin Ghafari Zeydabadi CS 284A, UC Berkeley



    Overview

    In this project we have simulated a clothe by assuming that it is a system of masses and springs. Where each mass is connected to its vertical and horizontal components through a spring and this connection is called Structural type of connection. These masses are also connected to thier diagonal neighbors by spring and these connections are called Shearing. The next connection is with the second vertical and horizontal neighbors which is called Bending connection. In the first part of the project we have positioned all the masses in their position based on the input of the cloth that is vertical or horizontal, and constructed a vector of mass points. Then, we implemented the connection between masses through construction of a vector of springs and specifying the type of connection and which point masses are connected through each connection.

    In the second part, We have computed the force applied on each point mass through the spring and gravity and updated the new position of each point mass based on its acceleration using Verlet integration method. We also check if in each time step the extension of the spring is more than 10% of lenght of the previous time step.

    In the third part, we prevent the cloth to pass through walls and sphere by using these primitives’ properties and detecting the collision between these object; thus, the resultant interaction between the clothes and the wall or sphere is close to reality. In th forth part, we implemented a method to detect collision between point masses of the clothes by itself. First based on the position of the point we hashed them to specific groups and checked for the distance between mass points. If the distance between them is less than some value then we move them in the same direction to avoid collision. To have unique float number for each nox in the hash map we first generated an integer number for each point mass using it coordinates. Then, we used this point and pairing function to generate a unique integer corresponding to one pair of numbers. We first converted all positive and negative values of the coordinates to postive values and using the paring function twice we were able to hash a unique float number for every hash box in the coordinates. https://en.wikipedia.org/wiki/Pairing_function

    Part I: Masses and springs

    No Shearing constraint
    Just Shearing constraint
    All constraints

    Part II: Simulation via numerical integration

    Ks:

    For the small ks the connection between mass spring is not strong and it behaves like a thin cloth or scarf that easily and fast drops when it is pinned at some points. In this case the cloth can bended easily and it has more flexibility.. For the large ks the connection between point is stronger and they are more connected to each other so the process of falling of the cloth feels like it is a thick cloth and it cannot be bended easily and it is not as flexible as a cloth should be. In fact it looks more like a foil of a metal.

    Density:

    For large densities the mass of the cloth will be large and because of that the spring get stretched more and when the cloth is pinned if seems that it is stretched more and it is bended in more locations. While for small masses this is not the case and the stretch between the points is less obvious in the cloth.

    Damping:

    Large damping causes the system easily lose it energy and there are less ripples in the clothes as it falls. It also prevents the cloth from falling fast because the energy inserted to the system is damped easily and the gravity helps the cloth to fall gradually. While for small dampings we see that the cloth falls very fast and it start swinging around its final equilibrium position since the damping is small and it takse more time for the system to lose its energy.

    Default Settigns, rest position for pinned4.json

    Part III: Handling collisions with other objects

    As we talked about ks, for large ks it is harder for the cloth to be bended and this obvious from the pictures below. For the smallest ks = 500, we can see that the cloth bend easily and it form the shape of the sphere easily. For large the large ks it is not easy to bend the cloth and the cloth does not form the shape of the sphere completely.

    ks = 5000
    ks = 500
    ks = 50000
    Cloth colliton with a plane

    Part IV: Handling self-collisions

    1
    2
    3
    4

    Large density: when density is large, it is as the ks is small. Thus, the cloth can easily bend over itself and stick to the floor as a thin cloth while for a cloth with small density the condition is reverse and the cloth is not going to bend easily.

    1
    2
    3
    4

    Large ks: for the large ks, bending is not as easy as before and even the cloth is on the floor it is like a foil of metal lying on surface.

    1
    2
    3
    4