World
-- -- Simple test -- > getOctantIndex (Pt (1.5,0,0)) (Pt (0,0,0),2) 1 -- -- Border case -- > getOctantIndex (Pt (0, 1, 0)) (Pt (0,0,0),2) 2 -- -- Border case -- > getOctantIndex (Pt (1, 0, 1)) (Pt (0,0,0),2) 5 -- -- Close to border -- > getOctantIndex (Pt (0.99,0,0)) (Pt (0,0,0), 2) 0 -- -- Voxel of size 2 -- > getOctants (Pt (1,1,1), 2) [(Pt (1.0,1.0,1.0),1.0),(Pt (2.0,1.0,1.0),1.0),(Pt (1.0,2.0,1.0),1.0),(Pt (2.0,2.0,1.0),1.0),(Pt (1.0,1.0,2.0),1.0),(Pt (2.0,1.0,2.0),1.0),(Pt (1.0,2.0,2.0),1.0),(Pt (2.0,2.0,2.0),1.0)] -- -- Voxel of size 1.5 -- > getOctants (Pt (0,0,0), 1.5) [(Pt (0.0,0.0,0.0),0.75),(Pt (0.75,0.0,0.0),0.75),(Pt (0.0,0.75,0.0),0.75),(Pt (0.75,0.75,0.0),0.75),(Pt (0.0,0.0,0.75),0.75),(Pt (0.75,0.0,0.75),0.75),(Pt (0.0,0.75,0.75),0.75),(Pt (0.75,0.75,0.75),0.75)] -- -- An OctTree that is just a leaf -- > mkOctTree (Pt (0,0,0), 5) [Object (Sphere (Pt (1,1,1)) 0.5) 0.1 0.2 (Col (1,1,1))] Leaf (Pt (0.0,0.0,0.0),5.0) [Object (Sphere (Pt (1.0,1.0,1.0)) 0.5) 0.1 0.2 (Col (1.0,1.0,1.0))] -- -- A more complicated OctTree -- > mkOctTree (Pt (0,0,0),2) [ Object (Sphere (Pt (0.5,0.5,0.5)) 0.1) 0.5 0.6 (Col (0.5, 0.7, 0.3)) , Object (Sphere (Pt (1.5, 0.5, 1.5)) 0.05) 0.25 0.35 (Col (1,1,1)) , Object (Sphere (Pt (1.5, 0.5, 1.5)) 0.1) 0.25 0.35 (Col (1,1,1)) , Object (Sphere (Pt (1.5, 0.5, 1.5)) 0.15) 0.25 0.35 (Col (1,1,1)) , Object (Sphere (Pt (1.5, 0.5, 1.5)) 0.20) 0.25 0.35 (Col (1,1,1)) , Object (Sphere (Pt (1.5, 0.5, 1.5)) 0.25) 0.25 0.35 (Col (1,1,1)) ] Node (Pt (0.0,0.0,0.0),2.0) [Leaf (Pt (0.0,0.0,0.0),1.0) [Object (Sphere (Pt (0.5,0.5,0.5)) 0.1) 0.5 0.6 (Col (0.5,0.7,0.3))], Leaf (Pt (1.0,0.0,0.0),1.0) [], Leaf (Pt (0.0,1.0,0.0),1.0) [], Leaf (Pt (1.0,1.0,0.0),1.0) [], Leaf (Pt (0.0,0.0,1.0),1.0) [], Leaf (Pt (1.0,0.0,1.0),1.0) [Object (Sphere (Pt (1.5,0.5,1.5)) 5.0e-2) 0.25 0.35 (Col (1.0,1.0,1.0)), Object (Sphere (Pt (1.5,0.5,1.5)) 0.1) 0.25 0.35 (Col (1.0,1.0,1.0)), Object (Sphere (Pt (1.5,0.5,1.5)) 0.15) 0.25 0.35 (Col (1.0,1.0,1.0)), Object (Sphere (Pt (1.5,0.5,1.5)) 0.2) 0.25 0.35 (Col (1.0,1.0,1.0)), Object (Sphere (Pt (1.5,0.5,1.5)) 0.25) 0.25 0.35 (Col (1.0,1.0,1.0))], Leaf (Pt (0.0,1.0,1.0),1.0) [], Leaf (Pt (1.0,1.0,1.0),1.0) []] -- -- findMinSize on previous OctTree (testOctTree) -- > findMinSize testOctTree 1.0
small_white_spheres.scn small_white_spheres.ppm
small_colour_spheres.scn small_colour_spheres.ppm
RayTrace
You can compile this test harness and run it. It should give output
equivalent to raytracetests.out
. If you haven't completed
all the functions in module RayTrace
yet then we suggest
that you load RayTraceTests
into GHCi and manually test
each function. e.g. type fi1
to test the
firstInteresect
function. Make sure you read the code of
the test harness. It will give you a good idea of how to write your
own (or extend the given one).
Below we've provided a (hand drawn) diagram of the scene in which the tests take place. You'll need to read the source code to understand it fully.
RayTraceTests.hs raytracestests.out