rustgd / cgmath

A linear algebra and mathematics library for computer graphics.
https://docs.rs/cgmath
Apache License 2.0
1.13k stars 155 forks source link

Add element-wise abs() #477

Open swiftcoder opened 5 years ago

swiftcoder commented 5 years ago

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.

Osspial commented 5 years ago

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

swiftcoder commented 5 years ago

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.