cgmath icon indicating copy to clipboard operation
cgmath copied to clipboard

Add element-wise abs()

Open swiftcoder opened this issue 6 years ago • 2 comments

Taking the element-wise absolute value of a vector is a pretty common operation in GLSL. It would be lovely to have an abs_element_wise().

Maybe also a .abs() added to VectorSpace for consistency with numeric types.

swiftcoder avatar Feb 09 '19 04:02 swiftcoder

You should be able to accomplish this with {vector/point}.map(|n| n.abs()).

Osspial avatar Feb 09 '19 23:02 Osspial

That is how I'm accomplishing this currently, but from my perspective it's a sufficiently common operation that it'd be nice to have it in the main API.

swiftcoder avatar Feb 10 '19 01:02 swiftcoder