aboutsummaryrefslogtreecommitdiff
path: root/vector.h
blob: 7e4dccba354afd22be2a2dae5138968b06a7c4f5 (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
31
32
33
34
35
36
#ifndef VECTOR_H
#define VECTOR_H
	
#define COORD_T double
#define ZERO_APROX 1e-6

typedef struct {
	COORD_T x;
	COORD_T y;
	COORD_T z;
} vector_t;

// Set vector to specified coordinates
vector_t *vector_set(vector_t *p, COORD_T x, COORD_T y, COORD_T z);

// Copy vector src
vector_t *vector_copy(vector_t *dest, vector_t *src);

// Calculate the length of v
COORD_T vector_len(vector_t *v);
void vector_norm(vector_t *v);

COORD_T vector_dot(vector_t *a, vector_t *b);

// Basic math functions
vector_t *vector_add(vector_t *dest, vector_t *a, vector_t *b);
vector_t *vector_sub(vector_t *dest, vector_t *a, vector_t *b);
vector_t *vector_mult(vector_t *dest, vector_t *a, vector_t *b);

vector_t *vector_cross(vector_t *dest, vector_t *a, vector_t *b);

vector_t *vector_scale(vector_t *dest, vector_t *a, COORD_T b);
vector_t *vector_scale_inv(vector_t *dest, vector_t *a, COORD_T b);

void vector_print(vector_t *v);
#endif