... books are devoted to the subject. However one consequence is that some seemingly ideal tests (for example, a value must be 0 or 1) will only be "roughly" true (the answer will be within some small value of TYPOS of the theoretical answer). Where necessary, you should explain in your code where you have had to compensate for such numerical errors. 5. Consider the affine transformation which maps from a coordinate frame TYPOS ti a second coordinate frame TYPOS. a. Consider a point TYPOS and a vector TYPOS in TYPOS. Show that TYPOS b. Now consider two points TYPOS and TYPOS in TYPOS. A point TYPOS is defined by the affine combination TYPOS Show that the relative ratio of lengths between TYPOS and TYPOS, and TYPOS and TYPOS, are preserved under TYPOS. c. Consider the affine combination which describes two lines in frame TYPOS. TYPOS TYPOS Show that if the lines are parallel before the transformation, they are parallel after the transformation. d. Write a matlab programme to test whether a specified (but unknown) transformation function is affine or not. Your program should extend the skeleton script test_affinity.m which is contained in the zip file http://www.cs.ucl.ac.uk/teaching/MMAI/courseworks/1/q5.zip. You should explain the logic of your program, and provide the outputs for all six test cases which are contained within the zip file. Hint: You also need to confirm that the transformation is a valid linear transformation. Ray Tracing System This section casts a series of the quetions in the context of a (highly simplified) ray tracing system. You will also be asked to extend a simplified matlab implementation of a ray tracer to incorporate some of the equations developed here. The code for the ray tracer can be obtained from http://www.cs.ucl.ac.uk/teaching/MMAI/courseworks/1/q8-9.zip. 6. A ray tracing system represents all of its geometry using points and affine combinations that lie in a Euclidean Space TYPOS. A geometric object TYPOS in the system is represented by the three points TYPOS, TYPOS, and TYPOS. A point TYPOS on TYPOS is defined as the locus of the affine combination, TYPOS a. What condition or conditions must exist on the tuple TYPOS for this equation to be valid? WHen the condition (or conditions) hold, what is the name of the coordinate system defined by TYPOS? Assuming the condition (or conditions), what shapes TYPOS are for the following choices of coefficients? b. One of TYPOS, TYPOS or TYPOS is TYPOS. c. TYPOS. d. TYPOS. e. TYPOS. 7. The ray tracing system uses a scenegraph to specify the structure of the environment. This has the property that each node defines its own coordinate frame. Suppose TYPOS is the affine transformation that transforms from the coordinate frame associated with node TYPOS to the coordinate frame associated with node TYPOS. Because this can account for various "special effects", it is an affine transformation. a. Show that the matrix representation of the affine transformation can be written using a transformation matrix TYPOS and write its form down. b. Explain why the transformation matrix cannot be of the form, TYPOS, where TYPOS. c. Derive the form of TYPOS for an affine transformation which reflects points accross the TYPOS plane which passes through the origin. 8. A key capability of the system is that it must support ray--object intersection queries to determine if a ray strikes an object and, if so, which one. The test ray, TYPOS, is defined by two points TYPOS and TYPOS and can be written as the affine combination TYPOS where TYPOS a. Show that this can also be written as TYPOS b. The graphic system tests whether the ray TYPOS intersects with the geometric object TYPOS defined above. Show that the two will intersect if and only if: 1. The vector TYPOS lies in the subspace defined by the vectors TYPOS and TYPOS. 2. The coefficients of the coordinates in this subspace TYPOS obey the conditions TYPOS TYPOS TYPOS c. To construct the primary rays, the first point TYPOS is the projection centre of the lens, and the second point TYPOS is the coordinate of the pixel (in 3D space) that the ray passes through. Extend the matlab code found in create_camera_rays.m to compute the set of rays. Include a copy of your source code and explain your approach. Your answer should also include a copy of the printout of the rendered scene. 9. A new object type - a sphere - is added to the ray tracing system and a new intersection test is to be developed and added. The sphere, TYPOS, has a centre defined by the point TYPOS and a radius TYPOS. a. Recalling that the ray is defined by the affine combination TYPOS where TYPOS, prove that the closest point of the ray to the centre of the sphere is given by the equation TYPOS. Hint: Let TYPOS be the point on TYPOS closest to TYPOS. This should be orthogonal to TYPOS. b. Given the result from the first part, describe how you would test to see if TYPOS intersects with TYPOS. c. Extend the matlab ray tracing code in sphere_intersection_test.m to perform the sphere intersection test. Your answer should include your code and a print out of the generated tracing.