Fix pixel to ray conversion (image flip)

Also fix test data in main.hs
diff --git a/Main.hs b/Main.hs
index c735607..855c511 100644
--- a/Main.hs
+++ b/Main.hs
@@ -9,7 +9,7 @@ For CSCI441: Computer Graphics, Fall 2012
 import Vector
 import World

-test = World { viewpoint         = Vector 0 1 40
+test = World { viewpoint         = Vector 0 0 40
              , screen_origin     = Vector (-1) (-1) 1
              , screen_horizontal = Vector 2 0 0
              , screen_vertical   = Vector 0 2 0
@@ -31,21 +31,21 @@ test = World { viewpoint         = Vector 0 1 40
                                                   , specular_coef = 0.4
                                                   , specular_exp = 1 }}
                             , Sphere { center = Vector (-0.5) 0.5 0
-                                     , radius = 2
+                                     , radius = 0.45
                                      , material =
                                          Material { diffuse = Color 0 0 1
                                                   , ambient = Color 0 0 1
                                                   , specular_coef = 0
                                                   , specular_exp = 1 }}
                             , Sphere { center = Vector (-0.5) (-0.5) 0
-                                     , radius = 2
+                                     , radius = 0.45
                                      , material =
                                          Material { diffuse = Color 1 1 1
                                                   , ambient = Color 1 1 1
                                                   , specular_coef = 0
                                                   , specular_exp = 1 }}
                             ,  Sphere { center = Vector 0 0 0
-                                     , radius = 2
+                                     , radius = 0.4
                                      , material =
                                          Material { diffuse = Color 1 1 0
                                                   , ambient = Color 1 1 0
diff --git a/World.hs b/World.hs
index 2f2ae38..0dce53e 100644
--- a/World.hs
+++ b/World.hs
@@ -106,16 +106,19 @@ first_intersection ray primitives =

 -- The ray point from the viewpoint to the center of the x,yth pixel of
 -- the width x height pixels of the rendered view
+-- x,y are offset from the top-left (image pixel coordinates)
 pixel_ray :: World -> Int -> Int -> Int -> Int -> Ray
 pixel_ray world width height x y =
   let e = viewpoint world
-      l = screen_origin world
+      o = screen_origin world
       v = screen_vertical world
       h = screen_horizontal world
       fi = fromIntegral
+      dx = h ^* (((fi x) + 0.5 ) / (fi width))
+      -- must transform from top-left pixel coords to bottom-left origin
+      dy = v ^* (((fi height - 1) - (fi y) + 0.5 ) / (fi height))
   in Ray { origin    = e
-         , direction = ((l + h ^* (((fi x) + 0.5) / (fi width))) +
-                        (l + v ^* (((fi y) + 0.5) / (fi height)))) - e
+         , direction = normal $ o + dx + dy - e
          }

 -- The pixels of a World rendered into width x height pixels
@@ -127,6 +130,6 @@ pixels world width height =
      in case first_intersection ray (primitives world) of
        Nothing        -> Color 0 0 0 -- background
        Just (prim, _) -> ambient . material $ prim
-  | y <- [0..(height - 1)]]
   | x <- [0..(width - 1)]]
+  | y <- [0..(height - 1)]]