// // Created by ary on 29.07.2026. // #include "helper.h" #include #include #include "structs.h" vec3 randUnitVector() { double x1,x2,lengthSquared; do { x1 = (rand() / (double) RAND_MAX) * 2 - 1; //random zahl zwischen -1 und 1 x2 = (rand() / (double) RAND_MAX) * 2 - 1; lengthSquared = x1 * x1 + x2 * x2; }while (lengthSquared >= 1); double weirdFactor = 2.0 * sqrt(1.0 - lengthSquared); return (vec3){ x1 * weirdFactor, x2 * weirdFactor, 1.0 - 2.0 * lengthSquared}; }