diff --git a/src/core/math/GroupD8.js b/src/core/math/GroupD8.js index 31c5d5e..1edb988 100644 --- a/src/core/math/GroupD8.js +++ b/src/core/math/GroupD8.js @@ -1,3 +1,5 @@ +// Your friendly neighbour https://en.wikipedia.org/wiki/Dihedral_group of order 16 + var ux = [1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1, 0, 1]; var uy = [0, 1, 1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1]; var vx = [0, -1, -1, -1, 0, 1, 1, 1, 0, 1, 1, 1, 0, -1, -1, -1]; @@ -66,7 +68,7 @@ N: 6, NE: 7, MIRROR_VERTICAL: 8, - MIRROR_HORIZONTAL: 10, + MIRROR_HORIZONTAL: 12, uX: function (ind) { return ux[ind]; }, @@ -91,9 +93,19 @@ sub: function (rotationSecond, rotationFirst) { return mul[rotationSecond][GroupD8.inv(rotationFirst)]; }, + /** + * Adds 180 degrees to rotation. Commutative operation + * @param rotation + * @returns {number} + */ rotate180: function (rotation) { - return rotation ^ 8; + return rotation ^ 4; }, + /** + * I dont know why sometimes width and heights needs to be swapped. We'll fix it later. + * @param rotation + * @returns {boolean} + */ isSwapWidthHeight: function(rotation) { return (rotation & 3) === 2; }, diff --git a/src/core/math/GroupD8.js b/src/core/math/GroupD8.js index 31c5d5e..1edb988 100644 --- a/src/core/math/GroupD8.js +++ b/src/core/math/GroupD8.js @@ -1,3 +1,5 @@ +// Your friendly neighbour https://en.wikipedia.org/wiki/Dihedral_group of order 16 + var ux = [1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1, 0, 1]; var uy = [0, 1, 1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1]; var vx = [0, -1, -1, -1, 0, 1, 1, 1, 0, 1, 1, 1, 0, -1, -1, -1]; @@ -66,7 +68,7 @@ N: 6, NE: 7, MIRROR_VERTICAL: 8, - MIRROR_HORIZONTAL: 10, + MIRROR_HORIZONTAL: 12, uX: function (ind) { return ux[ind]; }, @@ -91,9 +93,19 @@ sub: function (rotationSecond, rotationFirst) { return mul[rotationSecond][GroupD8.inv(rotationFirst)]; }, + /** + * Adds 180 degrees to rotation. Commutative operation + * @param rotation + * @returns {number} + */ rotate180: function (rotation) { - return rotation ^ 8; + return rotation ^ 4; }, + /** + * I dont know why sometimes width and heights needs to be swapped. We'll fix it later. + * @param rotation + * @returns {boolean} + */ isSwapWidthHeight: function(rotation) { return (rotation & 3) === 2; }, diff --git a/src/core/textures/TextureUvs.js b/src/core/textures/TextureUvs.js index 6bf607e..27042ca 100644 --- a/src/core/textures/TextureUvs.js +++ b/src/core/textures/TextureUvs.js @@ -29,7 +29,7 @@ * Sets the texture Uvs based on the given frame information * @param frame {PIXI.Rectangle} * @param baseFrame {PIXI.Rectangle} - * @param rotate {int} Rotation of frame, see {@link PIXI.GroupD8} + * @param rotate {number} Rotation of frame, see {@link PIXI.GroupD8} * @private */ TextureUvs.prototype.set = function (frame, baseFrame, rotate)