summaryrefslogtreecommitdiff
path: root/lib/vec2.c
blob: b417e9ca8bf52da01afcf0030324ad8479421b55 (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
37
38
39
40
41
42
43
44
45
46
#include "types.h"

vec2
dp_vec2_new(float x, float y)
{
	vec2 new;
	new.x = x;
	new.y = y;
	return new;
}

vec2
dp_vec2_add(vec2 a, vec2 b)
{
	vec2 new;
	new.x = a.x + b.x;
	new.y = a.y + b.y;
	return new;
}

vec2
dp_vec2_sub(vec2 a, vec2 b)
{
	vec2 new;
	new.x = a.x - b.x;
	new.y = a.y - b.y;
	return new;
}

vec2
dp_vec2_mul(vec2 vec, float scalar)
{
	vec2 new;
	new.x = vec.x * scalar;
	new.y = vec.y * scalar;
	return new;
}

vec2
dp_vec2_dot(vec2 a, vec2 b)
{
	vec2 dot;
	dot.x = a.x * b.x;
	dot.y = a.y * b.y;
	return dot;
}