aboutsummaryrefslogtreecommitdiff
path: root/src/math/vector.h
blob: 82e15135fb70c1d66db3a5c05a179ecd4c4a33ae (plain) (blame)
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
#ifndef MATH_VECTOR_H
#define MATH_VECTOR_H

namespace engine::math {

class Vector2 {
    public:
        float x, y;

        Vector2();
        Vector2(float x, float y);
        bool operator==(Vector2 other) const;
        bool operator!=(Vector2 other) const;
        Vector2 operator+() const;
        Vector2 operator-() const;
        Vector2 operator+(Vector2 other) const;
        Vector2 operator-(Vector2 other) const;
        float det(Vector2 other) const;
        Vector2 round() const;
};

Vector2 operator*(float n, Vector2 other);
Vector2 operator*(Vector2 other, float n);
Vector2 operator/(Vector2 other, float n);

class Vector3 {
    public:
        float x, y, z;

        Vector3();
        Vector3(float x, float y, float z);
        bool operator==(Vector3 other) const;
        bool operator!=(Vector3 other) const;
        Vector3 operator+() const;
        Vector3 operator-() const;
        Vector3 operator+(Vector3 other) const;
        Vector3 operator-(Vector3 other) const;
        Vector3 round() const;
        Vector3 cross(Vector3 other) const;
};

Vector3 operator*(float n, Vector3 other);
Vector3 operator*(Vector3 other, float n);
Vector3 operator/(Vector3 other, float n);

class Vector4 {
    public:
        float x, y, z, w;

        Vector4();
        Vector4(float x, float y, float z, float w);
        Vector4(float x, float y, float z);
        Vector4(Vector3 v, float w);
        Vector4(Vector3 v);
        bool operator==(Vector4 other) const;
        bool operator!=(Vector4 other) const;
        Vector4 operator+() const;
        Vector4 operator-() const;
        Vector4 operator+(Vector4 other) const;
        Vector4 operator-(Vector4 other) const;
        Vector4 round() const;
        Vector2 xy() const;
        Vector3 xyz() const;
        Vector4 div_by_w() const;
};

Vector4 operator*(float n, Vector4 other);
Vector4 operator*(Vector4 other, float n);
Vector4 operator/(Vector4 other, float n);

}

#endif // MATH_VECTOR_H