diff --git a/src/vec2-impl.ts b/src/vec2-impl.ts index 630f3a3..db45f51 100644 --- a/src/vec2-impl.ts +++ b/src/vec2-impl.ts @@ -646,7 +646,7 @@ export function transformMat3(v: Vec2, m: Mat3, dst?: Vec2): Vec2 { /** * Rotate a 2D vector - * + * * @param a The vec2 point to rotate * @param b The origin of the rotation * @param rad The angle of rotation in radians @@ -656,10 +656,10 @@ export function rotate(a: Vec2, b: Vec2, rad: number, dst?: Vec2) { dst = dst || new VecType(2); // Translate point to the origin - const p0 = a[0] - b[0], - p1 = a[1] - b[1], - sinC = Math.sin(rad), - cosC = Math.cos(rad); + const p0 = a[0] - b[0]; + const p1 = a[1] - b[1]; + const sinC = Math.sin(rad); + const cosC = Math.cos(rad); //perform rotation and translate to correct position dst[0] = p0 * cosC - p1 * sinC + b[0]; diff --git a/src/vec3-impl.ts b/src/vec3-impl.ts index c415a7b..a8eb263 100644 --- a/src/vec3-impl.ts +++ b/src/vec3-impl.ts @@ -790,7 +790,7 @@ export function getScaling(m: Mat4, dst: Vec3) { /** * Rotate a 3D vector around the x-axis - * + * * @param {ReadonlyVec3} a The vec3 point to rotate * @param {ReadonlyVec3} b The origin of the rotation * @param {Number} rad The angle of rotation in radians @@ -799,8 +799,9 @@ export function getScaling(m: Mat4, dst: Vec3) { */ export function rotateX(a: Vec3, b: Vec3, rad: number, dst?: Vec3) { dst = dst || new VecType(3); - let p = [], - r = []; + const p = []; + const r = []; + //Translate point to the origin p[0] = a[0] - b[0]; p[1] = a[1] - b[1]; @@ -821,7 +822,7 @@ export function rotateX(a: Vec3, b: Vec3, rad: number, dst?: Vec3) { /** * Rotate a 3D vector around the y-axis - * + * * @param {ReadonlyVec3} a The vec3 point to rotate * @param {ReadonlyVec3} b The origin of the rotation * @param {Number} rad The angle of rotation in radians @@ -830,8 +831,9 @@ export function rotateX(a: Vec3, b: Vec3, rad: number, dst?: Vec3) { */ export function rotateY(a: Vec3, b: Vec3, rad: number, dst?: Vec3) { dst = dst || new VecType(3); - let p = [], - r = []; + const p = []; + const r = []; + // translate point to the origin p[0] = a[0] - b[0]; p[1] = a[1] - b[1]; @@ -852,7 +854,7 @@ export function rotateY(a: Vec3, b: Vec3, rad: number, dst?: Vec3) { /** * Rotate a 3D vector around the z-axis - * + * * @param {ReadonlyVec3} a The vec3 point to rotate * @param {ReadonlyVec3} b The origin of the rotation * @param {Number} rad The angle of rotation in radians @@ -861,8 +863,9 @@ export function rotateY(a: Vec3, b: Vec3, rad: number, dst?: Vec3) { */ export function rotateZ(a: Vec3, b: Vec3, rad: number, dst?: Vec3) { dst = dst || new VecType(3); - let p = [], - r = []; + const p = []; + const r = []; + // translate point to the origin p[0] = a[0] - b[0]; p[1] = a[1] - b[1];