diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2015-11-16 16:32:09 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2015-12-15 11:41:58 -0800 |
commit | 4fc8226838a23154ca8acc5e5fcb6144de0794cb (patch) | |
tree | ac2354fda5e9bca147d7eb3f5bdddbaa291dc319 /src/mbgl/util/mat4.cpp | |
parent | 62412af6ab746dd8fb5b8984c75b3ff6e6b223e5 (diff) | |
download | qtlocation-mapboxgl-4fc8226838a23154ca8acc5e5fcb6144de0794cb.tar.gz |
[core] allow changing the orientation
You can now change the orientation of north to be to the right, bottom, left in addition to the default of top
Diffstat (limited to 'src/mbgl/util/mat4.cpp')
-rw-r--r-- | src/mbgl/util/mat4.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/mbgl/util/mat4.cpp b/src/mbgl/util/mat4.cpp index 0934cd081e..5f6f9d1b4c 100644 --- a/src/mbgl/util/mat4.cpp +++ b/src/mbgl/util/mat4.cpp @@ -214,6 +214,40 @@ void matrix::rotate_x(mat4& out, const mat4& a, double rad) { out[11] = a23 * c - a13 * s; } +void matrix::rotate_y(mat4& out, const mat4& a, double rad) { + double s = std::sin(rad), + c = std::cos(rad), + a00 = a[0], + a01 = a[1], + a02 = a[2], + a03 = a[3], + a20 = a[8], + a21 = a[9], + a22 = a[10], + a23 = a[11]; + + if (&a != &out) { // If the source and destination differ, copy the unchanged rows + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + } + + // Perform axis-specific matrix multiplication + out[0] = a00 * c - a20 * s; + out[1] = a01 * c - a21 * s; + out[2] = a02 * c - a22 * s; + out[3] = a03 * c - a23 * s; + out[8] = a00 * s + a20 * c; + out[9] = a01 * s + a21 * c; + out[10] = a02 * s + a22 * c; + out[11] = a03 * s + a23 * c; +} + void matrix::rotate_z(mat4& out, const mat4& a, double rad) { double s = std::sin(rad), c = std::cos(rad), |