#ifndef POLYGON_H #define POLYGON_H #include "fastmath.hpp" struct polygon { const vec3 points[3]; polygon(const vec3 &v1, const vec3 &v2, const vec3 &v3) : points{v1, v2, v3} {} bool contains(const vec3 &p) { for (int i = 0; i < 3; i++) { int n = (i + 1) % 3; vec3 d = points[n] - points[i]; d = vec3(d.y, -d.x, d.z); vec3 s = p - points[n]; if (s * d < decimal(0.0)) return false; } return true; } }; #endif