summaryrefslogtreecommitdiffstats
path: root/src/math
diff options
context:
space:
mode:
authorNikolay Korolev <nickvnuk@gmail.com>2019-06-26 22:34:14 +0200
committerNikolay Korolev <nickvnuk@gmail.com>2019-06-26 22:34:14 +0200
commit08b053a568e15dd318dcfc46eaa6393af4a5f8c4 (patch)
tree7e6a0bc15376f347c13029b99f2f0ec1427bf2c1 /src/math
parentMore replay stuff (diff)
parentbla (diff)
downloadre3-08b053a568e15dd318dcfc46eaa6393af4a5f8c4.tar
re3-08b053a568e15dd318dcfc46eaa6393af4a5f8c4.tar.gz
re3-08b053a568e15dd318dcfc46eaa6393af4a5f8c4.tar.bz2
re3-08b053a568e15dd318dcfc46eaa6393af4a5f8c4.tar.lz
re3-08b053a568e15dd318dcfc46eaa6393af4a5f8c4.tar.xz
re3-08b053a568e15dd318dcfc46eaa6393af4a5f8c4.tar.zst
re3-08b053a568e15dd318dcfc46eaa6393af4a5f8c4.zip
Diffstat (limited to 'src/math')
-rw-r--r--src/math/Matrix.h24
-rw-r--r--src/math/Rect.h16
2 files changed, 40 insertions, 0 deletions
diff --git a/src/math/Matrix.h b/src/math/Matrix.h
index 2ee3863f..e2e5394e 100644
--- a/src/math/Matrix.h
+++ b/src/math/Matrix.h
@@ -145,6 +145,30 @@ public:
m_matrix.pos.y = 0.0f;
m_matrix.pos.z = 0.0f;
}
+ void SetRotate(float xAngle, float yAngle, float zAngle) {
+ float cX = cos(xAngle);
+ float sX = sin(xAngle);
+ float cY = cos(yAngle);
+ float sY = sin(yAngle);
+ float cZ = cos(zAngle);
+ float sZ = sin(zAngle);
+
+ m_matrix.right.x = cZ * cY - (sZ * sX) * sY;
+ m_matrix.right.y = (cZ * sX) * sY + sZ * cY;
+ m_matrix.right.z = -cX * sY;
+
+ m_matrix.up.x = -sZ * cX;
+ m_matrix.up.y = cZ * cX;
+ m_matrix.up.z = sX;
+
+ m_matrix.at.x = (sZ * sX) * cY + cZ * sY;
+ m_matrix.at.y = sZ * sY - (cZ * sX) * cY;
+ m_matrix.at.z = cX * cY;
+
+ m_matrix.pos.x = 0.0f;
+ m_matrix.pos.y = 0.0f;
+ m_matrix.pos.z = 0.0f;
+ }
void Reorthogonalise(void){
CVector &r = *GetRight();
CVector &f = *GetForward();
diff --git a/src/math/Rect.h b/src/math/Rect.h
index d0824987..fd1bd05e 100644
--- a/src/math/Rect.h
+++ b/src/math/Rect.h
@@ -26,4 +26,20 @@ public:
if(v.y < top) top = v.y;
if(v.y > bottom) bottom = v.y;
}
+
+ void Translate(float x, float y){
+ left += x;
+ right += x;
+ bottom += y;
+ top += y;
+ }
+ void Grow(float r){
+ left -= r;
+ right += r;
+ top -= r;
+ bottom += r;
+ }
+
+ float GetWidth(void) { return right - left; }
+ float GetHeight(void) { return bottom - top; }
};