aboutsummaryrefslogtreecommitdiff
path: root/src/basic/math.cpp
blob: 81fcbbf09a1b3e4dac0415a980cb4079e10c4696 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <basic/math.hpp>

/* V2ST */

bool
V2ST::operator==(V2ST& b)
{
    bool result = this->x == b.x && this->y == b.y;
    return result;
}



/* V2F32 */

V2F32
V2F32::operator/(float scalar)
{
    V2F32 result {};
    result.x = this->x / scalar;
    result.y = this->y / scalar;
    return result;
}

V2F32
V2F32::operator*(float scalar)
{
    V2F32 result {};
    result.x = this->x * scalar;
    result.y = this->y * scalar;
    return result;
}

V2F32 V2F32::operator+(V2F32 other) {
    V2F32 result {};
    result.x = this->x + other.x;
    result.y = this->y + other.y;
    return result;
}


/* V3F32 */

V3F32 V3F32::operator/(float scalar) {
    V3F32 result = {};
    result.x = this->x / scalar;
    result.y = this->y / scalar;
    result.z = this->z / scalar;
    return result;
}

V3F32 V3F32::operator*(float scalar) {
    V3F32 result = {};
    result.x = this->x * scalar;
    result.y = this->y * scalar;
    result.z = this->z * scalar;
    return result;
}


/* V4F32 */

V4F32
V4F32::operator/(float scalar)
{
    V4F32 result {};
    result.x = this->x / scalar;
    result.y = this->y / scalar;
    result.z = this->z / scalar;
    result.w = this->w / scalar;
    return result;
}

V4F32
V4F32::operator*(float scalar)
{
    V4F32 result {};
    result.x = this->x * scalar;
    result.y = this->y * scalar;
    result.z = this->z * scalar;
    result.w = this->z * scalar;
    return result;
}


/* V2I32 */

bool
V2I32::operator==(V2I32 other)
{
    bool result = x == other.x && y == other.y;
    return result;
}