public Ray Refract(Point3D hp, float eta) { float nidot = Point3D.scalar(normal, casted_ray.dir); float k = 1.0f - eta * eta * (1.0f - nidot * nidot); if (k >= 0) { k = (float)Math.Sqrt(k); return(Ray.buildRay(hp, Point3D.norm(eta * casted_ray.dir - (k + eta * nidot) * normal))); } else { return(null); } }
public Ray Reflect(Point3D hp) { return(Ray.buildRay(hp, Point3D.norm(casted_ray.dir - 2 * normal * Point3D.scalar(normal, casted_ray.dir)))); }