aboutsummaryrefslogtreecommitdiff
path: root/ctranslate.h
blob: a2cc9b2bc619bb2a17934d2c4de72601b836ab01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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