NOC: Inspirations – Katie Pellegrino

Google Slides Presentation (Fractals)

fractal
https://www.pinterest.com/pin/332281278731529226/

This presentation provides a brief description and history of fractals, which, in programming, are created using a recursive function to iterate on itself, thus creating a repetitive patterned illusion. Fractals are an integral part of many generative forms of digital art and is also used in generating natural environments that mimic the real world.

NOC – Week 4: Forces – Katie Pellegrino

Assignment 4

Link to Assignment
Inspiration

For our assignment on applying forces to objects, I wanted to experiment with gravity and attempt a sketch for mutual attraction/repulsion. I was inspired by a scene in Blue Planet II in which sea turtles walk onto a beach to nest. I wanted to mimic how they appear to be attracted to each other’s walking, yet do not run into each other. In retrospect, I’m not sure if mutual attraction/repulsion is the best method to mimic this phenomena (especially without collision detection), however, it was super interesting to explore this concept in greater detail.

potato
Aerial view of sea turtles nesting on a beach. –BBC Blue Planet II–
Construction

The main sketch essentially does three main things. It first declares and sets up a class of Mover objects. Then in the ‘draw’ loop, it cycles through each mover in a ‘for’ loop, and then, for each mover, cycles through the mover objects again in a nested ‘for’ loop. Because each object should be attracted to the other, the nested ‘for’ loops allow each object to talk to each other object in order to define the amount of force that should be applied.

The amount of force applied is dependent on the object’s mass and the distance that they are from each other. Therefore, the ‘attract’ function, which is called for every object cycled through each object, essentially collects the objects’ distance from each other (magnitude of the vector made by subtracting the ‘currentPosition’ from the ‘targetPosition’) and the direction of the applied force by normalizing it. The method then determines the appropriate strength of the force by using the equation for gravity ((gravity constant * the mass of each object ) / distance squared) and multiplies this strength by the force vector (which previously only stored the direction). This force vector, which now has both direction and magnitude, is returned and applied to the object from the ‘for’ loop.

Finally, after the sketch has applied the force, it updates the objects and displays them. 

Part of my admiration of the image of the nesting turtles were the beautiful trails that they left behind in the sand. So I tried lowering the opacity of the background in my sketch to create this effect. My next goal was to consider switching the sketch from mutual attraction to mutual repulsion because the turtles were moving rather uniformly but not bumping into each other. Overall, however, neither mutual attraction or repulsion are a great method for making this phenomena happen because the turtles walk rather individually of each other. Perhaps the collision detection would’ve been a better implementation.

After concluding that the sketch was not going to mimic the nesting turtles, I decided to add a particle class just for fun. However, I didn’t apply their ‘update’ function so they are motionless figures. I think the stillness creates a nice contrast to the mutual attraction of the Movers class.

Final Remarks

Coding this sketch was quite confusing, but rewarding. I’m still interested in how to code a scene that mimics the nesting turtles, however, I learned a lot in this project about how to have objects interact with each other along with how to use gravitational attraction.

NOC – Week 3: Vectors – Katie Pellegrino

Assignment 3

UPDATED ASSIGNMENT 🙂

Link to Assignment

For assignment 3, I tried experimenting with classes and vectors. However, much of the code I couldn’t quite get to work. I think I’m still confused of the best approach between when it’s important to define a method within a class, when to define a new function, or when to simply write a few lines within the draw function. So using the best tactics in coding still confuses me a bit, but practice should help!

For this I defined a particle class made up of square objects. Each object is assigned position, velocity, and acceleration as vectors along with assigned size, rotation speed, scale factor, and color. The program initially creates an object every frame until it reaches 100. At first the objects are simply drawn and rotate in place wherever they are randomly generated. Then, after a mouseClick(), the objects update by adding velocity to their position. After the next mouseClick(), the objects update with acceleration added to the velocity. However, as we did in class, the acceleration must be recent each iteration so it’s not continuously increasing. Finally, after another mouseClick(), I remove acceleration and the objects begin to fluctuate size. 

Throughout, the edges are checked with a simple bounce() method, however, I also wanted to do something fun with color here. So, initially, the objects are assigned random colors in the blue spectrum (setting b value of rgb to 255 and ther est to random). But when they hit a wall, the objects update with a new color in the red spectrum (setting r value to 255, rest to random).

Additionally, I tried adding a rift. So that when the mouseY matches that of the object, the object expands. Additionally, I wanted to add a second class of circle objects that appear after the third click. Finally, I still wanted to try and connect the objects with lines if their distance was close enough to each other. But I still need to practice the distance function more to fully understand it.  

Overall, I have a much better understanding of vectors and they significantly simplify the logic of creating visuals.

UPDATE

The updated program adds an additional 4th update function that first reduces the particles to a uniform size before applying acceleration towards the direction of the mouse.

NOC – Week 2: OOP – Katie Pellegrino

Assignment 2

Link to Assignment

After browsing the internet, I found inspiration for my sketch. My sketch looks nothing like the sketch that inspired me, however, it helped me think about the possibilities of p5 and think deeper about coding.

I first created the Particles class, similar to in class. I tested having the particles move with Perlin Noise, however, this made them shake like an earthquake. Instead, I left them moving at random speeds along with leaving their initial placement as a random place on the screen.

I used Perlin Noise to adjust the size of the particles. which gave the impression that they were breathing. I played around with using the particles with a fill color or with an outline, and settled on having them outlined because it made them look almost like cells. I then adjusted the background to gradually increase and decrease transparency, thus allowing the particles to periodically leave trails behind simulating odd cell/slugs.

My initial idea, which can be found commented out in my code file, was to attempt to draw a line between dots if they are within a certain distance from each other. But I had trouble implementing the distance formula correctly.

Another unsuccessful implementation was the shuffle(); method which I originally wanted to be a mouse interaction in which the dots scatter from the mouse. So if the mouse gets too close to the particles, they move away from it. But similarly, I wasn’t sure how to implement a distance function. So I adjusted the method to be essentially the wind(); method from our class example.

Overall, I found that using OOP really helps to organize the code and make the process much more logical.