[csu540-f05-rpf] Programming Assignment 2

Robert Futrelle futrelle at ccs.neu.edu
Sun Oct 2 19:12:24 EDT 2005


I'll discuss this in some detail tomorrow, Monday, morning.
But briefly, you can replace the method traceOne in TinyRayTrace by
traceOne(solarSystem, raye, rayd, i, j).  The first vector raye,
as you can see from the code I gave you, is actually just a position
in space, on the postive z-axis and at i,j for x and y.  The
second vector, rayd is a fixed, constant vector that is parallel
to the z-axis and in the minus z-direction.

Your traceOne, for a fixed i,j will simply do the intersection
with each planet and choose the smallest t of all hits (if any).
You could have a boolean, hitAny initially false, and a planetID,
initially null, and a tHit value, initially 0.0.  Then update
them when and if you get a hit, always updating with the smallest
t value found so far if there are any hits at all (if you ever
set hitAny to true). Save a reference to the planet at the
smallest tHit.  Use that planet to decide on the color of
the pixel.  If none, leave the pixel at the initially set
background color.  Since I've told you what the vectors are,
you should be able to construct the coefficients in the
quadratic and solve it, first checking the discriminant for
a non-hit.

My suggestions above are based on a discussion I had with a
student in the class who helpfully made an appointment with
me Friday afternoon so we could discuss exactly the points
above.  So you should thank this anonymous student for asking
earlier for my quick and detailed reply.

  - Prof. Futrelle


>I've started the programming assignment 2 and I have some problems trying
>to figure it out how to implement the Ray-Sphere intersection foumula in
>the book. What are d and e? And how do we draw the sphere when the ray has
>intersected a point in the sphere? Does this Ray-sphere intersection work
>like the Ray-Triangle Intersection where the ray intersects all the points
>inside the triangle?
>
>-Philip Lee Lee-
>
>_______________________________________________
>csu540-f05-rpf mailing list
>csu540-f05-rpf at lists.ccs.neu.edu
>https://lists.ccs.neu.edu/bin/listinfo/csu540-f05-rpf




More information about the csu540-f05-rpf mailing list