diff --git a/src/vec2.ts b/src/vec2.ts index 3c1fe3f..413f808 100644 --- a/src/vec2.ts +++ b/src/vec2.ts @@ -213,6 +213,10 @@ export namespace vec2 { ] } + export function abs(v: vec2): vec2 { + return [Math.abs(v[0]), Math.abs(v[1])] + } + /** * symmetric round the components of a vec2 */ diff --git a/src/vec3.ts b/src/vec3.ts index 2c6e384..c2dba29 100644 --- a/src/vec3.ts +++ b/src/vec3.ts @@ -306,6 +306,10 @@ export namespace vec3 { ] } + export function abs(v: vec3): vec3 { + return [Math.abs(v[0]), Math.abs(v[1]), Math.abs(v[2])] + } + /** * symmetric round the components of a vec3 */ diff --git a/src/vec4.ts b/src/vec4.ts index 56a5100..be12110 100644 --- a/src/vec4.ts +++ b/src/vec4.ts @@ -196,6 +196,10 @@ export namespace vec4 { */ export const div = divide + export function abs(v: vec4): vec4 { + return [Math.abs(v[0]), Math.abs(v[1]), Math.abs(v[2]), Math.abs(v[3])] + } + /** * symmetric round the components of a vec4 */