summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2014-08-26 15:24:16 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2014-10-17 10:44:38 -0700
commit4603ca037cab2d0f732285ce9e006744ad3118d6 (patch)
tree0c14ef89bfc59a4501f63fb34e89bfc8ce6ccb01 /src/util
parent48a310406621957db4154e844d28e98f460a0226 (diff)
downloadqtlocation-mapboxgl-4603ca037cab2d0f732285ce9e006744ad3118d6.tar.gz
background-image support
Diffstat (limited to 'src/util')
-rw-r--r--src/util/mat3.cpp46
1 files changed, 45 insertions, 1 deletions
diff --git a/src/util/mat3.cpp b/src/util/mat3.cpp
index 38858d2385..263768ee41 100644
--- a/src/util/mat3.cpp
+++ b/src/util/mat3.cpp
@@ -38,7 +38,51 @@ void matrix::identity(mat3& out) {
out[8] = 1.0f;
}
-void matrix::scale(mat3& out, const mat3& a, const float x, const float y) {
+void matrix::translate(mat3& out, const mat3& a, float x, float y) {
+ float a00 = a[0], a01 = a[1], a02 = a[2],
+ a10 = a[3], a11 = a[4], a12 = a[5],
+ a20 = a[6], a21 = a[7], a22 = a[8];
+
+ out[0] = a00;
+ out[1] = a01;
+ out[2] = a02;
+
+ out[3] = a10;
+ out[4] = a11;
+ out[5] = a12;
+
+ out[6] = x * a00 + y * a10 + a20;
+ out[7] = x * a01 + y * a11 + a21;
+ out[8] = x * a02 + y * a12 + a22;
+}
+
+void matrix::rotate(mat3& out, const mat3& a, float rad) {
+ float s = std::sin(rad),
+ c = std::cos(rad),
+ a00 = a[0],
+ a01 = a[1],
+ a02 = a[2],
+ a10 = a[3],
+ a11 = a[4],
+ a12 = a[5],
+ a20 = a[6],
+ a21 = a[7],
+ a22 = a[8];
+
+ out[0] = c * a00 + s * a10;
+ out[1] = c * a01 + s * a11;
+ out[2] = c * a02 + s * a12;
+
+ out[3] = c * a10 - s * a00;
+ out[4] = c * a11 - s * a01;
+ out[5] = c * a12 - s * a02;
+
+ out[6] = a20;
+ out[7] = a21;
+ out[8] = a22;
+};
+
+void matrix::scale(mat3& out, const mat3& a, float x, float y) {
out[0] = x * a[0];
out[1] = x * a[1];
out[2] = x * a[2];