init: first commit - rendering triangle

This commit is contained in:
2025-11-04 11:23:39 +01:00
commit a921fb27b1
4 changed files with 257 additions and 0 deletions

29
polygon.hpp Normal file
View File

@@ -0,0 +1,29 @@
#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