diff --git a/src/gl-matrix/mat2d.js b/src/gl-matrix/mat2d.js index b6dc5250..47678809 100644 --- a/src/gl-matrix/mat2d.js +++ b/src/gl-matrix/mat2d.js @@ -226,6 +226,27 @@ export function rotate(out, a, rad) { return out; } +/** + * Skew (shear) a mat2d by the given angle + * + * @param {mat2d} out the receiving matrix + * @param {mat2d} a the matrix to skew + * @param {Number} rad the angle to skew the matrix by + * @param {Number} rad the angle to skew the matrix by + * @returns {mat2d} out + */ +export function skew(out, a, radX, radY) { + let x = Math.tan(radX); + let y = Math.tan(radY); + out[0] = a[0]; + out[1] = a[1] + x; + out[2] = a[2] + y; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + return out; +} + /** * Scales the mat2d by the dimensions in the given vec2 *