-
Notifications
You must be signed in to change notification settings - Fork 0
/
vec2.c
99 lines (81 loc) · 1.38 KB
/
vec2.c
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
* Author: Enes Kaya ÖCAL
* Purpose: 2D vector operations
* Date : 03.03.2018
* Language: C
*/
#include "vec2.h"
VEC2* vec2(float x, float y)
{
VEC2* vec = (VEC2*)malloc(sizeof(VEC2));
vec->x = x;
vec->y = y;
return vec;
}
void vec2_inc(VEC2* vec, float x, float y)
{
vec->x += x;
vec->y += y;
}
void vec2_dup(VEC2* vec, float x, float y)
{
vec->x *= x;
vec->y *= y;
}
VEC2* vec2_sum(VEC2* vec, VEC2* vec2)
{
}
VEC2_SHORT* vec2_short(short x, short y)
{
VEC2_SHORT* vec = (VEC2_SHORT*)malloc(sizeof(VEC2_SHORT));
vec->x = x;
vec->y = y;
return vec;
}
void vec2_inc_short(VEC2_SHORT* vec, short x, short y)
{
vec->x += x;
vec->y += y;
}
void vec2_dup_short(VEC2_SHORT* vec, short x, short y)
{
vec->x *= x;
vec->y *= y;
}
void vec2_add_short(VEC2_SHORT* vec, VEC2_SHORT* vec2)
{
vec->x += vec2->x;
vec->y += vec2->y;
}
void vec2_set_short(VEC2_SHORT* vec, short x, short y)
{
vec->x = x;
vec->y = y;
}
VEC2_INT* vec2_int(int x, int y)
{
VEC2_INT* vec = (VEC2_INT*)malloc(sizeof(VEC2_INT));
vec->x = x;
vec->y = y;
return vec;
}
void vec2_inc_int(VEC2_INT* vec, int x, int y)
{
vec->x += x;
vec->y += y;
}
void vec2_dup_int(VEC2_INT* vec, int x, int y)
{
vec->x *= x;
vec->y *= y;
}
void vec2_add_int(VEC2_INT* vec, VEC2_INT* vec2)
{
vec->x += vec2->x;
vec->y += vec2->y;
}
void vec2_set_int(VEC2_INT* vec, int x, int y)
{
vec->x = x;
vec->y = y;
}