Skip to main content

Posts

Showing posts from October, 2015

CGI Sphere

Over my fall break (which lasted 1 day), I wrote a JavaScript program that would render a sphere. I thought it would be a fun way to practice math and programming skills simultaneously. As usual, I used my FireTools.js library to help with graphics as well as some other functions. To render the sphere, I wanted to take every pixel on the screen, and calculate the color of the pixel. The color would vary depending on which part of the sphere the pixel was displaying. If the part of the sphere was facing the light source, it would need to be brighter than a part of the sphere facing away from the light source. To find the brightness of each point on the surface, I first calculated the XYZ coordinates of that part of the sphere. This is also equal to the normal vector at that point. I took the dot product between the light source's direction and the normal vector. This is a mathematical operation that tells me whether the surface is aligned with the light source, as well as the percen

Lunar Eclipse

Near the end of last month, the moon passed entirely through Earth's shadow, resulting in a full lunar eclipse. The moon didn't completely black out, due to sunlight scattering through Earth's atmosphere. Instead, the moon had a dim reddish-brown glow. Of course, I took I lot of photos of this celestial phenomenon. I started taking photos during totality. I kept taking photos a couple times per minute, for a period of about 1.25 hours, until the moon was fully lit. My goal was to put the photos together, for an animation of the moon passing through the shadow of the Earth. "Fake" crescent One thing I thought was pretty neat was when the partial lighting of the moon formed a perfect crescent. The crescent looked a lot like the waning crescent phase of the moon, but there was something strange about it. It reminded me of the artificial images of the moon that you'll see when you use a star-mapping program. The reason is this: for a real crescent moon, the lighti