Request: Vec3 helper functions
Closed this issue · 2 comments
Hello! Not sure if this is the right spot for this but I was converting my project to use ultraviolet instead of my own Vec3 library and there were some ease-of-use functions that I am missing. These are the following:
Vec3 from single value
Something like Vec3::from(0.5)
which would initialize the Vec3 as (0.5, 0.5, 0.5)
.
Reciprocal
Something like Vec3::recip()
or Vec3::reciprocal()
which would return a Vec3 with each of the components replaced by their reciprocal. Would need appropriate divide-by-zero handling.
Get Orthonormal Basis
Function that returns an orthonormal basis for a given Vec3. This is maybe a bit too exotic for this crate but might be still useful. I see you added this as an extension in rayn, so I guess there might be a reason not to add it to uv.
If any/all/none of these are a good addition in your opinion, I can try to make a PR for it but I'm not sure if you think these kind of functions are within the scope of the crate, or just unnecessary bloat. Personally I think they fit in. Thanks in advance!
Vec3::from
as you've described is what VecN::broadcast
does :) Would probably be good to add doc comment that explains that :P
reciprocal and orthonormal basis seems like fine things to add, would accept pr!
Vec3::from
as you've described is whatVecN::broadcast
does :) Would probably be good to add doc comment that explains that :Preciprocal and orthonormal basis seems like fine things to add, would accept pr!
Awesome! Will see what I can do :)