summaryrefslogtreecommitdiffstats
path: root/src/math
diff options
context:
space:
mode:
authorNikolay Korolev <nickvnuk@gmail.com>2019-11-09 14:44:36 +0100
committerNikolay Korolev <nickvnuk@gmail.com>2019-11-09 14:44:36 +0100
commit5ef291ddf27aed2c27b39c3c30a9d5d27f7548b9 (patch)
tree710f5904ec705a30d64a568ce5f3ede0e2d91690 /src/math
parentscript stubs (diff)
parentFix link to config.h in readme (diff)
downloadre3-5ef291ddf27aed2c27b39c3c30a9d5d27f7548b9.tar
re3-5ef291ddf27aed2c27b39c3c30a9d5d27f7548b9.tar.gz
re3-5ef291ddf27aed2c27b39c3c30a9d5d27f7548b9.tar.bz2
re3-5ef291ddf27aed2c27b39c3c30a9d5d27f7548b9.tar.lz
re3-5ef291ddf27aed2c27b39c3c30a9d5d27f7548b9.tar.xz
re3-5ef291ddf27aed2c27b39c3c30a9d5d27f7548b9.tar.zst
re3-5ef291ddf27aed2c27b39c3c30a9d5d27f7548b9.zip
Diffstat (limited to 'src/math')
-rw-r--r--src/math/Vector.h36
-rw-r--r--src/math/Vector2D.h13
2 files changed, 31 insertions, 18 deletions
diff --git a/src/math/Vector.h b/src/math/Vector.h
index 42087339..605d96ab 100644
--- a/src/math/Vector.h
+++ b/src/math/Vector.h
@@ -78,21 +78,6 @@ public:
bool IsZero(void) { return x == 0.0f && y == 0.0f && z == 0.0f; }
};
-inline float
-DotProduct(const CVector &v1, const CVector &v2)
-{
- return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
-}
-
-inline CVector
-CrossProduct(const CVector &v1, const CVector &v2)
-{
- return CVector(
- v1.y*v2.z - v1.z*v2.y,
- v1.z*v2.x - v1.x*v2.z,
- v1.x*v2.y - v1.y*v2.x);
-}
-
inline CVector operator+(const CVector &left, const CVector &right)
{
return CVector(left.x + right.x, left.y + right.y, left.z + right.z);
@@ -117,3 +102,24 @@ inline CVector operator/(const CVector &left, float right)
{
return CVector(left.x / right, left.y / right, left.z / right);
}
+
+inline float
+DotProduct(const CVector &v1, const CVector &v2)
+{
+ return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
+}
+
+inline CVector
+CrossProduct(const CVector &v1, const CVector &v2)
+{
+ return CVector(
+ v1.y*v2.z - v1.z*v2.y,
+ v1.z*v2.x - v1.x*v2.z,
+ v1.x*v2.y - v1.y*v2.x);
+}
+
+inline float
+Distance(const CVector &v1, const CVector &v2)
+{
+ return (v2 - v1).Magnitude();
+} \ No newline at end of file
diff --git a/src/math/Vector2D.h b/src/math/Vector2D.h
index a090155c..1e4d698f 100644
--- a/src/math/Vector2D.h
+++ b/src/math/Vector2D.h
@@ -49,9 +49,6 @@ public:
CVector2D operator+(const CVector2D &rhs) const {
return CVector2D(x+rhs.x, y+rhs.y);
}
- CVector2D operator*(float t) const {
- return CVector2D(x*t, y*t);
- }
CVector2D operator/(float t) const {
return CVector2D(x/t, y/t);
}
@@ -91,3 +88,13 @@ NormalizeXY(float &x, float &y)
}else
x = 1.0f;
}
+
+inline CVector2D operator*(const CVector2D &left, float right)
+{
+ return CVector2D(left.x * right, left.y * right);
+}
+
+inline CVector2D operator*(float left, const CVector2D &right)
+{
+ return CVector2D(left * right.x, left * right.y);
+}