160 likes | 310 Views
How to get a perfect score. By Johnny Ho. Why get a perfect score?. Free Gold Medal Pride Beat Gennady Korotkevich 2009-2011: 1st place 2012: 2nd place Fame Get Interviewed Get mentioned at rallies (but don't go and play frisbee outside instead) GIRLS
E N D
How to get a perfect score By Johnny Ho
Why get a perfect score? • Free Gold Medal • Pride • Beat Gennady Korotkevich • 2009-2011: 1st place • 2012: 2nd place • Fame • Get Interviewed • Get mentioned at rallies (but don't go and play frisbee outside instead) • GIRLS • Many, many girls will be gazing at your face all day • You will need a priority queue to handle them all • Johnny Ho has many many girls.
Computer graphics the actual meeting topic
How to draw a point • Fill in a pixel: • *applause*
How to draw on an LCD screen • Most LCDs come with three channels • Mix the red, green, and blue channels to make colors
How to draw a line segment • Imagine the bounding box of the line segment • Take the maximum of the two dimensions • Sweep across that dimension and fill in the corresponding pixel
How to draw a polygon • To be lazy, first decompose into triangles • How to draw a triangle: • Sweep across y coordinate and fill in points that lie within left and right intersection • Round x coordinates properly to avoid aliasing
How to draw text (very trickily) • Remember this? • Take advantage of subpixel structure • Calibri 8pt, zoomed in: • Microsoft ClearType • ~3x horizontal resolution • Variation in color is largely undetectable by human eye
How to draw a 3d object • Again, first decompose into triangles • Give each triangle a color depending on angle towards light source • How to draw a 3D triangle: • Apply a perspective transformation • Basically, just divide x and y coordinates by z coordinate to obtain x' and y' coordinates • Then draw 2d triangle
Demo • Link • [code not included because of ugliness] • Z-buffering • Save Z coordinate as well as actual colors • Determine which pixels of the object are closer to camera • Interpolation • Interpolate between the three points of each triangle to improve smoothness
Phong shading • Adds a specular layer • Previously named techniques only incorporate diffuse • Results in plastic texture
Raytracing Credits to http://users.softlab.ntua.gr/~ttsiod/renderer.html for his amazing renderer/raytracer
Solution to last week's PotW Find # common factors = # factors of gcd int ans=0, g=gcd(n, m); for(int i=1;i*i<=g;i++) { if(g%i==0) { ans+=2; if(i*i==g) ans--; } } return ans; public int gcd(int a, int b) { return b==0 ? a : gcd(b, a%b); }
PotW • Go home and search up more awesome computer graphics stuff! :D • (no, you don't actually get points for this)