WUT_Computer_Science/code/photonmapping/cpp/Plane.h
kuhyx 21511cf816
parameters and statistics for c++ version of photonmapping (#7)
* feat: load exr map

* feat: scale and flip the hdr map

* feat: added camera

* feat: add simple slow but working photonmapping

* feat: added cpp version of photonmapping

* chore: extracted vector class to separate file

* chore: split classes into separate files

* chore: removed constant parameters from main

* feat: added statistics to main cpp

* feat: added statistic for time of execution
2025-01-19 17:54:56 +01:00

27 lines
782 B
C++

#ifndef PLANE_H
class Plane {
public:
Vector3 point; // A point on the plane
Vector3 normal; // Normal to the plane
Vector3 color;
Plane(const Vector3& p, const Vector3& n, const Vector3& col)
: point(p), normal(n.normalize()), color(col) {}
bool intersect(const Vector3& ray_origin, const Vector3& ray_direction, double& t, Vector3& hit_point, Vector3& hit_normal) const {
double denom = normal.dot(ray_direction);
if (std::abs(denom) > 1e-6) {
t = (point - ray_origin).dot(normal) / denom;
if (t >= 1e-4) {
hit_point = ray_origin + ray_direction * t;
hit_normal = normal;
return true;
}
}
return false;
}
};
#endif