コード例 #1
0
 private IEnumerable<ISect> Intersections(Ray ray, Scene scene)
 {
     return scene.Things
                 .Select(obj => obj.Intersect(ray))
                 .Where(inter => inter != null)
                 .OrderBy(inter => inter.Dist);
 }
コード例 #2
0
        private Color TraceRay(Ray ray, Scene scene, int depth)
		{
            var isects = Intersections(ray, scene);
            ISect isect = isects.FirstOrDefault();
            if (isect == null)
                return Color.Background;
            return Shade(isect, scene, depth);
        }
コード例 #3
0
        private double TestRay(Ray ray, Scene scene)
		{
            var isects = Intersections(ray, scene);
            ISect isect = isects.FirstOrDefault();
            if (isect == null)
                return 0;
            return isect.Dist;
        }
コード例 #4
0
 public IEnumerable<ISect> Intersect(Ray r) {
     return from thing in Things
            select thing.Intersect(r);
 }
コード例 #5
0
 public override ISect Intersect(Ray ray) {
     double denom = Vector.Dot(Norm, ray.Dir);
     if (denom > 0) return null;
     return new ISect() {
         Thing = this,
         Ray = ray,
         Dist = (Vector.Dot(Norm, ray.Start) + Offset) / (-denom)};
 }
コード例 #6
0
 public override ISect Intersect(Ray ray) {
     Vector eo = Vector.Minus(Center, ray.Start);
     double v = Vector.Dot(eo, ray.Dir);
     double dist;
     if (v < 0) {
         dist = 0;
     }
     else {
         double disc = Math.Pow(Radius,2) - (Vector.Dot(eo, eo) - Math.Pow(v,2));
         dist = disc < 0 ? 0 : v - Math.Sqrt(disc);
     }
     if (dist == 0) return null;
     return new ISect() {
         Thing = this,
         Ray = ray,
         Dist = dist};
 }
コード例 #7
0
 public abstract ISect Intersect(Ray ray);