#include "kdtree.h" #include int main() { // Testing triangles Triangle t1 = Triangle(Vector(0.0, 0.0, 0.0), Vector(2.0, 0.0, 0.0), Vector(0.0, 2.0, 0.0)); Triangle t2 = Triangle(Vector(0.5, 0.0, 0.0), Vector(1.0, 1.0, 0.0), Vector(1.0, 1.0, 1.0)); // Create list of all points from triangles std::vector points = t1.create_point_objects(); std::vector other_points = t2.create_point_objects(); points.insert(points.end(), other_points.begin(), other_points.end()); // Create and print the KDTree resulting from these points KDTree tree = KDTree(points); std::cout << tree.to_string(); // Intersection check Triangle *intersection = tree.intersect_ray(Ray(new float[3]{0.5, 0.5, -1.0}, new float[3]{0.0, 0.1, 1.0})); if (intersection != nullptr) { std::cout << "Hit!" << std::endl; } return 0; }