This repository has been archived on 2024-12-30. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
2024CG-project-render/include/Triangle.h
github-classroom[bot] 5d6a4935ec
Initial commit
2024-09-26 09:17:55 +00:00

25 lines
692 B
C++

#ifndef TRIANGLE_H
#define TRIANGLE_H
#include "Object.h"
#include <Eigen/Core>
class Triangle : public Object
{
public:
// A triangle has three corners
std::tuple< Eigen::Vector3d, Eigen::Vector3d, Eigen::Vector3d> corners;
// Intersect a triangle with ray.
//
// Inputs:
// Ray ray to intersect with
// min_t minimum parametric distance to consider
// Outputs:
// t first intersection at ray.origin + t * ray.direction
// n surface normal at point of intersection
// Returns iff there a first intersection is found.
bool intersect(
const Ray & ray, const double min_t, double & t, Eigen::Vector3d & n) const;
};
#endif