bool in_shadow(Surface* surface) { // check if ray from surface to light , hits light or is stopped by an object Eigen::Vector3f light_direction = (this->light_point - surface->point).normalized(); Ray shadow_ray = Ray(surface->point, light_direction); float x = (this->light_point.x() - surface->point.x()) * (this->light_point.x() - surface->point.x()); float y = (this->light_point.y() - surface->point.y()) * (this->light_point.y() - surface->point.y()); float z = (this->light_point.z() - surface->point.z()) * (this->light_point.z() - surface->point.z()); float distance_bw_light_point = std::sqrt(x + y + z); for (const auto& s : get_surfaces()) { if (s != surface && s->ray_intersection(shadow_ray) && ((s->point - surface->point).norm() <= distance_bw_light_point)) { return true; } } return false; }