public Ray make_ray(double x, double y) { //s = e + ux + vy − wd // d = s − e Ray r = new Ray(eye, u.scale(x).add(v.scale(y).subtract(w.scale(this.dist)))); //System.out.println("x:" + x + " y: " + y + " D: " + r.direction); r.direction.normalize(); return(r); }
public void add_reflection(Vec3 hit_point, Geometry o, int recursion_level) { Vec3 n = o.get_surface_n(hit_point); // reflection = 2(n · v)n - v Vec3 r_dir = n.scale((2 * n.dot(Program.proj.eye))).subtract(Program.proj.eye); r_dir.normalize(); Ray reflection = new Ray(hit_point, r_dir); reflection.prev_hit_id = o.get_id(); //System.out.println("Level: " + recursion_level); bool r_hit = reflection.trace(recursion_level + 1); if (r_hit) { // add in reflection reflection.ret_color.scalar_update(o.reflectiveness); this.ret_color.add_reflection(reflection.ret_color); } }