MCPcopy Index your code
hub / github.com/apache/groovy / ray_trace

Method ray_trace

benchmark/bench/raytracer.java:69–79  ·  view source on GitHub ↗
(Vec light, Ray ray, Scene scene)

Source from the content-addressed store, hash-verified

67 }
68 }
69 double ray_trace(Vec light, Ray ray, Scene scene) {
70 Hit i = scene.intersect(new Hit(infinity, new Vec(0, 0, 0)), ray);
71 if (i.lambda == infinity) return 0;
72 Vec o = add(ray.orig, add(scale(i.lambda, ray.dir),
73 scale(delta, i.normal)));
74 double g = dot(i.normal, light);
75 if (g >= 0) return 0.;
76 Ray sray = new Ray(o, scale(-1, light));
77 Hit si = scene.intersect(new Hit(infinity, new Vec(0, 0, 0)), sray);
78 return (si.lambda == infinity ? -g : 0);
79 }
80 Scene create(int level, Vec c, double r) {
81 Sphere sphere = new Sphere(c, r);
82 if (level == 1) return sphere;

Callers 1

runMethod · 0.95

Calls 4

addMethod · 0.95
scaleMethod · 0.95
dotMethod · 0.95
intersectMethod · 0.65

Tested by

no test coverage detected