aboutsummaryrefslogtreecommitdiff
path: root/src/Math/Vec2i.c
blob: 7f3bc6487cd7c5449f37398767821d6d463b3f4c (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
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
#include <BH/Math.h>


void BH_Vec2iAdd(const int a[2],
                 const int b[2],
                 int out[2])
{
    out[0] = a[0] + b[0];
    out[1] = a[1] + b[1];
}


void BH_Vec2iSub(const int a[2],
                 const int b[2],
                 int out[2])
{
    out[0] = a[0] - b[0];
    out[1] = a[1] - b[1];
}


void BH_Vec2iMul(const int a[2],
                 const int b[2],
                 int out[2])
{
    out[0] = a[0] * b[0];
    out[1] = a[1] * b[1];
}


void BH_Vec2iScale(const int a[2],
                   int b,
                   int out[2])
{
    out[0] = a[0] * b;
    out[1] = a[1] * b;
}


void BH_Vec2iMulAdd(const int a[2],
                    const int b[2],
                    const int c[2],
                    int out[2])
{
    out[0] = a[0] * b[0] + c[0];
    out[1] = a[1] * b[1] + c[1];
}


void BH_Vec2iNegate(const int in[2],
                    int out[2])
{
    out[0] = -in[0];
    out[1] = -in[1];
}


void BH_Vec2iMin(const int a[2],
                 const int b[2],
                 int out[2])
{
    if (a[0] < b[0]) out[0] = a[0]; else out[0] = b[0];
    if (a[1] < b[1]) out[1] = a[1]; else out[1] = b[1];
}


void BH_Vec2iMax(const int a[2],
                 const int b[2],
                 int out[2])
{
    if (a[0] > b[0]) out[0] = a[0]; else out[0] = b[0];
    if (a[1] > b[1]) out[1] = a[1]; else out[1] = b[1];
}