aboutsummaryrefslogtreecommitdiff
path: root/src/math
diff options
context:
space:
mode:
Diffstat (limited to 'src/math')
-rw-r--r--src/math/mat4.cpp4
-rw-r--r--src/math/mat4.h4
-rw-r--r--src/math/math_vector.cpp20
-rw-r--r--src/math/math_vector.h4
4 files changed, 22 insertions, 10 deletions
diff --git a/src/math/mat4.cpp b/src/math/mat4.cpp
index ece42d8..6418e9c 100644
--- a/src/math/mat4.cpp
+++ b/src/math/mat4.cpp
@@ -3,6 +3,8 @@
#include <cmath>
#include "math/math_vector.h"
+using namespace engine::math;
+
Mat4 Mat4::idty() {
return {
1.f, 0.f, 0.f, 0.f,
@@ -127,7 +129,7 @@ std::array<MathVector4, 4> Mat4::to_vecs() {
}};
}
-Mat4 operator*(float fac, Mat4 m) {
+Mat4 engine::math::operator*(float fac, Mat4 m) {
return {
fac * m.values[ 0], fac * m.values[ 1], fac * m.values[ 2], fac * m.values[ 3],
fac * m.values[ 4], fac * m.values[ 5], fac * m.values[ 6], fac * m.values[ 7],
diff --git a/src/math/mat4.h b/src/math/mat4.h
index 6df9d49..d8b66c4 100644
--- a/src/math/mat4.h
+++ b/src/math/mat4.h
@@ -4,6 +4,8 @@
#include <array>
#include "math/math_vector.h"
+namespace engine::math {
+
class Mat4 {
public:
static Mat4 idty();
@@ -27,4 +29,6 @@ class Mat4 {
Mat4 operator*(float fac, Mat4 m);
+}
+
#endif // MATH_MAT4_H
diff --git a/src/math/math_vector.cpp b/src/math/math_vector.cpp
index baa2448..aacff86 100644
--- a/src/math/math_vector.cpp
+++ b/src/math/math_vector.cpp
@@ -1,6 +1,8 @@
#include "math/math_vector.h"
#include <cmath>
+using namespace engine::math;
+
MathVector2::MathVector2() {
}
@@ -39,15 +41,15 @@ MathVector2 MathVector2::round() const {
return { std::round(x), std::round(y) };
}
-MathVector2 operator*(float n, MathVector2 other) {
+MathVector2 engine::math::operator*(float n, MathVector2 other) {
return { n * other.x, n * other.y };
}
-MathVector2 operator*(MathVector2 other, float n) {
+MathVector2 engine::math::operator*(MathVector2 other, float n) {
return n * other;
}
-MathVector2 operator/(MathVector2 other, float n) {
+MathVector2 engine::math::operator/(MathVector2 other, float n) {
return { other.x / n, other.y / n };
}
@@ -97,15 +99,15 @@ MathVector3 MathVector3::cross(MathVector3 other) const {
};
}
-MathVector3 operator*(float n, MathVector3 other) {
+MathVector3 engine::math::operator*(float n, MathVector3 other) {
return { n * other.x, n * other.y, n * other.z };
}
-MathVector3 operator*(MathVector3 other, float n) {
+MathVector3 engine::math::operator*(MathVector3 other, float n) {
return n * other;
}
-MathVector3 operator/(MathVector3 other, float n) {
+MathVector3 engine::math::operator/(MathVector3 other, float n) {
return { other.x / n, other.y / n, other.z / n };
}
@@ -160,14 +162,14 @@ MathVector3 MathVector4::div_by_w() const {
return xyz() / w;
}
-MathVector4 operator*(float n, MathVector4 other) {
+MathVector4 engine::math::operator*(float n, MathVector4 other) {
return { n * other.x, n * other.y, n * other.z, n * other.w };
}
-MathVector4 operator*(MathVector4 other, float n) {
+MathVector4 engine::math::operator*(MathVector4 other, float n) {
return n * other;
}
-MathVector4 operator/(MathVector4 other, float n) {
+MathVector4 engine::math::operator/(MathVector4 other, float n) {
return { other.x / n, other.y / n, other.z / n, other.w / n };
}
diff --git a/src/math/math_vector.h b/src/math/math_vector.h
index 668a3f3..28ae81e 100644
--- a/src/math/math_vector.h
+++ b/src/math/math_vector.h
@@ -1,6 +1,8 @@
#ifndef MATH_MATH_VECTOR_H
#define MATH_MATH_VECTOR_H
+namespace engine::math {
+
class MathVector2 {
public:
float x, y;
@@ -66,4 +68,6 @@ MathVector4 operator*(float n, MathVector4 other);
MathVector4 operator*(MathVector4 other, float n);
MathVector4 operator/(MathVector4 other, float n);
+}
+
#endif // MATH_MATH_VECTOR_H