summaryrefslogtreecommitdiff
path: root/src/math/Vector.cpp
diff options
context:
space:
mode:
authorclaude-bot <[email protected]>2026-07-13 12:27:07 +0000
committerclaude-bot <[email protected]>2026-07-13 12:27:07 +0000
commit9f61c9e6ac6b1ac5692cf6352d2ebbd47a31a686 (patch)
treea84756b82513739a2672db3a1f0ec579db6d18ff /src/math/Vector.cpp
downloadre3-miami.tar.gz
re3-miami.zip
Import Cai1Hsu/re3 @ miami (reVC / GTA:VC decompilation)HEADmiami
Snapshot import (no upstream history) into git.ancap.in.ua/claude, per @lzcnt. Source: https://github.com/Cai1Hsu/re3 branch miami.
Diffstat (limited to 'src/math/Vector.cpp')
-rw-r--r--src/math/Vector.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/math/Vector.cpp b/src/math/Vector.cpp
new file mode 100644
index 0000000..ee76e55
--- /dev/null
+++ b/src/math/Vector.cpp
@@ -0,0 +1,46 @@
+#include "common.h"
+
+void
+CVector::Normalise(void)
+{
+ float sq = MagnitudeSqr();
+ if (sq > 0.0f) {
+ float invsqrt = RecipSqrt(sq);
+ x *= invsqrt;
+ y *= invsqrt;
+ z *= invsqrt;
+ } else
+ x = 1.0f;
+}
+
+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);
+}
+
+CVector
+Multiply3x3(const CMatrix &mat, const CVector &vec)
+{
+ // TODO: VU0 code
+ return CVector(mat.rx * vec.x + mat.fx * vec.y + mat.ux * vec.z,
+ mat.ry * vec.x + mat.fy * vec.y + mat.uy * vec.z,
+ mat.rz * vec.x + mat.fz * vec.y + mat.uz * vec.z);
+}
+
+CVector
+Multiply3x3(const CVector &vec, const CMatrix &mat)
+{
+ return CVector(mat.rx * vec.x + mat.ry * vec.y + mat.rz * vec.z,
+ mat.fx * vec.x + mat.fy * vec.y + mat.fz * vec.z,
+ mat.ux * vec.x + mat.uy * vec.y + mat.uz * vec.z);
+}
+
+CVector
+operator*(const CMatrix &mat, const CVector &vec)
+{
+ // TODO: VU0 code
+ return CVector(mat.rx * vec.x + mat.fx * vec.y + mat.ux * vec.z + mat.px,
+ mat.ry * vec.x + mat.fy * vec.y + mat.uy * vec.z + mat.py,
+ mat.rz * vec.x + mat.fz * vec.y + mat.uz * vec.z + mat.pz);
+}