Skip to content

Commit

Permalink
Add vec.abs
Browse files Browse the repository at this point in the history
  • Loading branch information
baku89 committed Mar 4, 2024
1 parent 68602ac commit 5067023
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/vec2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
4 changes: 4 additions & 0 deletions src/vec3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
4 changes: 4 additions & 0 deletions src/vec4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 5067023

Please sign in to comment.