3d Graphics

Home

Alice


As an introduction to the concepts of 3d graphic based programming, we started with the programming application called Alice. Similar to Scratch, Alice is drag and drop-based programming app and is therefore easy to use for beginners. In this app, I created a program that shows the rotation of the earth in space while the moon orbits around it. The moon and the earth were both built in instances of Alice that simply had to be dragged onto the screen. To make the moon orbit the earth, I programmed the moon to constantly point towards the earth while slowly sliding to the left. Repeating this process would inevitably lead the moon to stray farther and farther away from the earth, so I programmed a separate loop to monitor the distance between the earth and the moon and move the moon closer as soon as it strays beyond a certain distance. The light representing the direction of the sun was a characteristic that was relatively easy to rotate in the same direction as the moon. However, as far as I could tell, there was no option to force the moon and the light to rotate at the exact same rate, so I had to approximate the right numbers as close as possible. Finally, similar to the light, rotating the earth was a built in command and easy to program. The video below shows one "year" of orbit. However, for demonstration purposes, the speed of the earth's rotation is 1/15th the speed required to rotate 365 times.



Sketch Up


Having programmed with pre-built 3d objects, we then started designing our own. Google Sketch Up is an app that allows the user to create objects on a three dimentional coordinate grid. Various functions within the programmed helped me create realistic and unrealistic shapes. In the first picture below, I created what I call squareiangles, (squares and triangles) in order to become acquainted with Sketch Up interface. Then, using digital measurements, rectangles, and circles, I created a proportionally correct ping pong ball and paddle.




Python


In Visual Python, we expanded what we already learned from Alice into a more complex programming language. We used vectors and spheres to simulate gravity within our programs. Starting with a ball and a platform, we first learned how to make the ball fall, bounce up, and fall back down again by changing vectors that represent the sphere's coordinate positions in a loop. After a tutorial with one dimension, we were given free time to explore 2 dimensional and 3 dimensional bouncing. Adding dimensions turned out to be as simple as adding x and z directional vector forces on the sphere. In the end, I created a cube in which the ball bounced around.




After exploring the capabilities of a bouncing ball, we expanded our knowledge of simulated gravity into creating planetary orbit. To do so, we had to substitute the downwards gravitational force with Newton's vector equation for universal gravitational force. Within the program's loop, all of the variables were constantly being updated in order to keep the earth in orbit around the sun.