CS6620 Assignment1

From Dangerski

Revision as of 01:43, 15 February 2008 by WikiSysop (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

[edit] CS 6620 Assignment 1

Image:prog01.png Reference Image generated by my ray tracer


Source Code Source Code

[edit] Creative Image

Image:creative1.png

This is a box with a pyramid of spheres on top of it. There is also a ring casting a shadow on the spheres.


Image:creative.png

This has multiple rings.


[edit] Extra Credit

Tori

Image:tori.png Image:torisizes.png

I used the intersection method outlined in the Ray Tracing from the ground up book. It requires solving a quartic equation because you can have up to 4 intersection points. I borrowed code from the web for solving that.

The equation for the torus is: \left [ ( x^2 + z^2 )^{1/2} - a  \right ]^2  + y^2 - b^2

Squaring gives the implicit equation for a generic torus

f(x,y,z) = (x2 + y2 + z2) − 2(a2 + b2)(x2 + y2 + z2) + 4a2y2 + (a2b2)2 = 0

where a = swept radius and b = tube radius


You substitute the ray equation and get a 4th degree polynomial:

c4t4 + c3t3 + c2t2 + c1t + c0 = 0

Then you solve for c4,c3,c2,c1,c0

For the normal calculation you use the gradient: \overrightarrow{n} = \nabla f(x,y,z) = ({\partial f}/{\partial x}, {\partial f}/{\partial y}, {\partial f}/{\partial z} )

Personal tools