use math::{Point, Vector};

use cgmath::prelude::*;
use cgmath::ApproxEq;

#[derive(Copy, Clone)]
pub struct Ray {
    pub origin: Point,
    pub direction: Vector,
}

impl Ray {
    pub fn new(origin: Point, direction: Vector) -> Ray {
        debug_assert!(direction.magnitude().approx_eq(&1.0),
                      "Ray direction is not normalized. (|{:?}| == {:?} != 1.0)",
                      direction,
                      direction.magnitude());

        Ray {
            origin: origin,
            direction: direction,
        }
    }

    pub fn evaluate(&self, distance: f32) -> Point {
        self.origin + self.direction * distance
    }
}

use math::{Point, Vector};

#[derive(Copy, Clone)]
pub struct Ray {
    pub origin: Point,
    pub direction: Vector,
}

impl Ray {
    pub fn evaluate(&self, distance: f32) -> Point {
        self.origin + self.direction * distance
    }
}

--- 
+++ 
@@ -1,4 +1,7 @@
 use math::{Point, Vector};
+
+use cgmath::prelude::*;
+use cgmath::ApproxEq;
 
 #[derive(Copy, Clone)]
 pub struct Ray {
@@ -7,6 +10,18 @@
 }
 
 impl Ray {
+    pub fn new(origin: Point, direction: Vector) -> Ray {
+        debug_assert!(direction.magnitude().approx_eq(&1.0),
+                      "Ray direction is not normalized. (|{:?}| == {:?} != 1.0)",
+                      direction,
+                      direction.magnitude());
+
+        Ray {
+            origin: origin,
+            direction: direction,
+        }
+    }
+
     pub fn evaluate(&self, distance: f32) -> Point {
         self.origin + self.direction * distance
     }
Add a `Ray::new()` method that ensures the direction is normalized
