When two objects collide with one another in the physical world, nature doesn’t require a different procedure to calculate the collision’s effect upon each possible shape – rectangle, triangle, ellipse and so forth. Computationally, it is much more straightforward to calculate whether a regular shape such as those listed above has experienced a collision than it is to do so for an irregular shape. Yet, any procedure that works for irregular shapes should also work for regular ones.
As a starting place, I envisioned a dynamic scenario that involved both regular and irregular geometries: a cloth bag filled with marbles being dropped from some height onto the ground. In an attempt to deal with this scenario in a “universal” manner, I decided to think of all parts of this system being composed of the same type of thing, which we will call particles. The size of a particle can vary and it can either exist freely or be constrained to other particles. So the marbles are large, unconstrained particles and points along the bag’s surface are small particles, which are tied to one another in the sense that one particle and the next cannot be more than a certain distance apart. This constraint can be extended to include the property of stretchiness. From here, we apply any forces – gravity, air turbulence, etc – to all particles and scale the effect of each force based on the mass of each particle. So far, I have implemented the bag portion of this simulation. Next I will add the marbles. Without the marbles, the bag feels more like a chain necklace. More to come.
Here is a video of the bag in action:
Here is the source code:
In the process of creating the particle bag, I did a few tests to get the hang of using polar coordinates. To initialize the bag, I set the particles around the circumference of a circle using polar coordinates to do so. This way of representing coordinates is ideal for this purpose and I can’t think of an easy or efficient way to achieve the same effect without them. So for the purpose of meeting the oscillation goals of this week’s assignment, I wrote the following: