From a9651189ac52139c374f97a311d090a8d95b957e Mon Sep 17 00:00:00 2001 From: Julian T Date: Thu, 26 Mar 2020 21:47:51 +0100 Subject: MOved hemisphere transformation stuff out of ray.c --- ctranslate.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 ctranslate.h (limited to 'ctranslate.h') diff --git a/ctranslate.h b/ctranslate.h new file mode 100644 index 0000000..a2cc9b2 --- /dev/null +++ b/ctranslate.h @@ -0,0 +1,30 @@ +#ifndef CTRANS_H +#define CTRANS_H + +#include "vector.h" + +// Used to create a sort of "virtual" coordinate system where up is defined by a given vector +// Implemented from https://www.scratchapixel.com/lessons/3d-basic-rendering/global-illumination-path-tracing/global-illumination-path-tracing-practical-implementation +// These methods assume y is up + +typedef struct { + vector_t *up; + + // These are calculated from the given up vector + vector_t ax; + vector_t az; +} csystem_t; + +// Inits the given csystem_t with a given up vector. +// Will overwrite everything in cs +void csystem_init(csystem_t *cs, vector_t *up); + +// Translates the inside coordinates to real and saves them in real. +// Will overwrite real +void csystem_calc_real(csystem_t *cs, vector_t *inside, vector_t *real); + +// Writes the inside coordinates of a random direction in the upper hemisphere, and saves in out +// One must provide random numbers r1 and r2 between 0 and 1 +void csystem_hemisphere_random(csystem_t *cs, COORD_T r1, COORD_T r2, vector_t *out); + +#endif -- cgit v1.2.3