-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibvec.h
56 lines (44 loc) · 1.89 KB
/
libvec.h
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* libvec.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbetz <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/02 11:33:22 by rbetz #+# #+# */
/* Updated: 2024/02/02 11:28:28 by rbetz ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef LIBVEC_H
# define LIBVEC_H
# include <stdio.h>
# include <stdbool.h>
# include <math.h>
typedef struct s_vector
{
double x;
double y;
double z;
} t_vec;
t_vec add_vectors(t_vec v1, t_vec v2);
t_vec subtract_vectors(t_vec v1, t_vec v2);
t_vec multiply_vectors(t_vec v1, t_vec v2);
t_vec multiply_vector_by_scalar(t_vec v1, double scalar);
t_vec divide_vector_by_scalar(t_vec v1, double scalar);
double dot_product(t_vec v1, t_vec v2);
t_vec cross_product(t_vec v1, t_vec v2);
t_vec normalize_vector(t_vec v1);
t_vec random_vector(unsigned int seed);
t_vec random_vector_in_unit_sphere(int seed);
t_vec random_vector_in_hemisphere(int seed, t_vec normal);
t_vec new_vector(double x, double y, double z);
t_vec invert_vector(t_vec vec);
t_vec abs_vector(t_vec color);
double length_vector(t_vec v1);
double length_squared(t_vec vector);
void print_vector(t_vec vector);
bool are_equal_vectors(t_vec a, t_vec b);
int lcg_random(unsigned int seed);
int xorshift_random(int seed);
int xslcg_random(unsigned int seed);
#endif