private Color GetNaturalColor(SceneObject thing, Vector pos, Vector norm, Vector rd, Scene scene)
		{
            Color ret = Color.Make(0, 0, 0);
            foreach (Light light in scene.Lights) {
                Vector ldis = Vector.Minus(light.Pos, pos);
                Vector livec = Vector.Norm(ldis);
                double neatIsect = TestRay(new Ray() { Start = pos, Dir = livec }, scene);
                bool isInShadow = !((neatIsect > Vector.Mag(ldis)) || (neatIsect == 0));
                if (!isInShadow) {
                    double illum = Vector.Dot(livec, norm);
                    Color lcolor = illum > 0 ? Color.Times(illum, light.Color) : Color.Make(0, 0, 0);
                    double specular = Vector.Dot(livec, Vector.Norm(rd));
                    Color scolor = specular > 0 ? Color.Times(Math.Pow(specular, thing.Surface.Roughness), light.Color) : Color.Make(0, 0, 0);
                    ret = Color.Plus(ret, Color.Plus(Color.Times(thing.Surface.Diffuse(pos), lcolor),
                                                     Color.Times(thing.Surface.Specular(pos), scolor)));
                }
            }
            return ret;
        }
        private Color GetReflectionColor(SceneObject thing, Vector pos, Vector norm, Vector rd, Scene scene, int depth)
		{
            return Color.Times(thing.Surface.Reflect(pos), TraceRay(new Ray() { Start = pos, Dir = rd }, scene, depth + 1));
        }
 public override Vector Normal(Vector pos) {
     return Norm;
 }
 public abstract Vector Normal(Vector pos);
 public override Vector Normal(Vector pos) {
     return Vector.Norm(Vector.Minus(pos, Center));
 }
 public static bool Equals(Vector v1, Vector v2) {
     return (v1.X == v2.X) && (v1.Y == v2.Y) && (v1.Z == v2.Z);
 }
        public static Camera Create(Vector pos, Vector lookAt) {
            Vector forward = Vector.Norm(Vector.Minus(lookAt, pos));
            Vector down = new Vector(0, -1, 0);
            Vector right = Vector.Times(1.5, Vector.Norm(Vector.Cross(forward, down)));
            Vector up = Vector.Times(1.5, Vector.Norm(Vector.Cross(forward, right)));

            return new Camera() { Pos = pos, Forward = forward, Up = up, Right = right };
        }
 public static Vector Norm(Vector v) {
     double mag = Mag(v);
     double div = mag == 0 ? double.PositiveInfinity : 1 / mag;
     return Times(div, v);
 }
 public static Vector Cross(Vector v1, Vector v2) {
     return new Vector(((v1.Y * v2.Z) - (v1.Z * v2.Y)),
                       ((v1.Z * v2.X) - (v1.X * v2.Z)),
                       ((v1.X * v2.Y) - (v1.Y * v2.X)));
 }
 public static double Mag(Vector v) { return Math.Sqrt(Dot(v, v)); }
 public static double Dot(Vector v1, Vector v2) {
     return (v1.X * v2.X) + (v1.Y * v2.Y) + (v1.Z * v2.Z);
 }
 public static Vector Plus(Vector v1, Vector v2) {
     return new Vector(v1.X + v2.X, v1.Y + v2.Y, v1.Z + v2.Z);
 }
 public static Vector Minus(Vector v1, Vector v2) {
     return new Vector(v1.X - v2.X, v1.Y - v2.Y, v1.Z - v2.Z);
 }
 public static Vector Times(double n, Vector v) {
     return new Vector(v.X * n, v.Y * n, v.Z * n);
 }