Assignment 1 – Planes and Cylinders




Assignment 1 – Planes and Cylinders

In this assignment, you will implement ray intersections with planes and cylinders and compute surface normals at the intersection points. The framework code provided this weekisidenticaltolastweek’s,except“todo”commentshavebeeninsertedinPlane.cpp and Cylinder.cpp toindicatewhereyouneedtoaddyourimplementations. Ifyoualready set up a GitHub repository last week to collaborate with your fellow group members, you can copy these TODO comments over to your repository (or just note where your implementation needs to go and get started). In the expected_results directory, we provide the images you should expect your finishedcodetoproduceforasubsetoftheprovidedscenes. Onesuchresultisshownin Figure1. Theframeworkisconfiguredtovisualizethesurfacenormalsinfalsecolor(the normal XZY components in [−1,1] are mapped linearly to RGB values in [0,1]).
Notes on Implementing Cylinder Intersections
You are asked to compute the intersection with an open cylinder (i.e. without end caps). The approach we recommend you take is to first determine where the ray intersects a versionofthecylinderthatextendsinfinitelyineachdirection(asif height = ∞). Then, from this list of intersection candidates, discard those that fall outside the cylinder’s actual extent. Finally, choose the first remaining intersection that appears in front of the viewer. Hint: you may find it helpful to read over Sphere::intersect in Sphere.cpp.
Theory Exercise
Derivetheformulasyouusetosolveforthecylinderintersectionsandcomputenormals. Forfullcredit,thederivationmustbecomplete(endingwiththeformulasyouimplement in Cylinder.cpp) and possible to follow.
Each part of this assignment is weighted as follows:
• Ray-plane intersection: 20% • Ray-cylinder intersection + normal derivations (theory exercise): 25% • Ray-cylinder intersection implementation: 40% • Cylinder normal implementation: 15%
What to hand in
A.zipcompressedfilerenamedto where N isthenumberof the current exercise sheet and I is the number of your group. It should contain only: • The files you changed (in this case, Plane.cpp and Sphere.cpp) and the requested program output. It is your responsibility to ensure that all files that you have changed are in the zip. • A readme.txt file containing a description on how you solved each exercise and theencounteredproblems. Indicatewhatfractionofthetotalworkloadeachproject member contributed. • Otherfilesthatarerequiredbyyourreadme.txtfile. Forexample,ifyoumention some screenshot images in readme.txt, these images need to be submitted too. • A TheoryExercise.pdf containing your cylinder-ray intersection derivations.