From 74e1cea0b92c80e5710e7ca0b55566f226eb443d Mon Sep 17 00:00:00 2001 From: Guillermo Gombau Date: Thu, 20 Sep 2018 14:13:24 +0200 Subject: [PATCH] Add vec2#rotate --- types/gl-matrix/gl-matrix-tests.ts | 1 + types/gl-matrix/index.d.ts | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/types/gl-matrix/gl-matrix-tests.ts b/types/gl-matrix/gl-matrix-tests.ts index cf9c4ef616..e557acf79d 100644 --- a/types/gl-matrix/gl-matrix-tests.ts +++ b/types/gl-matrix/gl-matrix-tests.ts @@ -74,6 +74,7 @@ outVec2 = vec2.cross(outVec3, vec2A, vec2B); outVec2 = vec2.lerp(outVec2, vec2A, vec2B, 0.5); outVec2 = vec2.random(outVec2); outVec2 = vec2.random(outVec2, 5.0); +outVec2 = vec2.rotate(outVec2, vec2A, vec2B, Math.PI * 0.5); outVec2 = vec2.transformMat2(outVec2, vec2A, mat2A); outVec2 = vec2.transformMat2d(outVec2, vec2A, mat2dA); outVec2 = vec2.transformMat3(outVec2, vec2A, mat3A); diff --git a/types/gl-matrix/index.d.ts b/types/gl-matrix/index.d.ts index 2c86b6a057..33db200cd6 100644 --- a/types/gl-matrix/index.d.ts +++ b/types/gl-matrix/index.d.ts @@ -374,6 +374,17 @@ declare module 'gl-matrix' { */ public static random(out: vec2, scale: number): vec2; + /** + * Rotate a 2D vector + * + * @param out The receiving vec2 + * @param a The vec2 point to rotate + * @param b The origin of the rotation + * @param c The angle of rotation + * @returns out + */ + public static rotate(out: vec2, a: vec2, b: vec2, c: number): vec2; + /** * Transforms the vec2 with a mat2 * @@ -1959,13 +1970,13 @@ declare module 'gl-matrix' { * @returns out */ public static transpose(out: mat3, a: mat3): mat3; - + /** * Generates a 2D projection matrix with the given bounds * * @param out the receiving matrix * @param width width of your gl context - * @param height height of gl context + * @param height height of gl context * @returns out */ public static projection(out: mat3, width: number, height: number): mat3; @@ -2510,9 +2521,9 @@ declare module 'gl-matrix' { public static getTranslation(out: vec3, mat: mat4): vec3; /** - * Returns the scaling factor component of a transformation matrix. - * If a matrix is built with fromRotationTranslationScale with a - * normalized Quaternion parameter, the returned vector will be + * Returns the scaling factor component of a transformation matrix. + * If a matrix is built with fromRotationTranslationScale with a + * normalized Quaternion parameter, the returned vector will be * the same as the scaling vector originally supplied. * @param {vec3} out Vector to receive scaling factor component * @param {mat4} mat Matrix to be decomposed (input)