public bool IsShadowed(Light l, Tuple p) { Tuple v = l.Position - p; float distance = v.Magnitude(); Tuple direction = v.Normalize(); Ray r = new Ray(p, direction); List <Intersection> intersections = Intersection(r); RayTracer.Intersection h = RayTracer.Intersection.Hit(intersections); return((h != null) && (h.T < distance)); }
private Tuple NormalToWorld(Tuple normal) { normal = Transform.Inverse().Transpose() * normal; normal.W = 0; normal = normal.Normalize(); if (Parent != null) { normal = Parent.NormalToWorld(normal); } return(normal); }