-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvec3.h
More file actions
61 lines (33 loc) · 1.02 KB
/
vec3.h
File metadata and controls
61 lines (33 loc) · 1.02 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#pragma once
#include <stdbool.h>
#include <stdint.h>
// Struct definition for a 3 dimensional vector.
typedef struct {
double x, y, z;
} vec3;
typedef vec3 color; // Use same struct definition for when referring to a color
vec3 v3_init(double, double, double);
double v3_length_squared(vec3);
double v3_length(vec3);
vec3 v3_add(vec3, vec3);
vec3 v3_sub(vec3, vec3);
double v3_dot(vec3, vec3);
vec3 v3_cross(vec3, vec3);
vec3 v3_hadamard(vec3 u, vec3 v);
vec3 v3_scale(vec3, double);
vec3 v3_unit_vector(vec3);
void v3_normalize(vec3 *);
vec3 v3_lerp(vec3, vec3, double);
vec3 v3_random_uniform();
vec3 v3_random_range(double min, double max);
vec3 random_in_unit_sphere();
vec3 random_unit_vector();
vec3 random_in_hemisphere(vec3 normal);
bool v3_near_zero(vec3 v);
vec3 v3_reflect(vec3 v, vec3 n);
vec3 v3_refract(vec3 uv, vec3 n, double etai_over_etat);
vec3 random_in_unit_disk();
bool v3_compare(vec3 a, vec3 b, uint8_t axis);
vec3 v3_min(vec3 u, vec3 v);
vec3 v3_max(vec3 u, vec3 v);
void v3_print(vec3);