Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<typename T> Vector3<T> RandomUnitVector3()
- {
- while (true)
- {
- Vector3<T> ret;
- for (i64 c = 0; c < ret.ElementCount; ++c)
- ret[c] = (T)(RandFloat() * 2 - 1);
- T len = Mag(ret);
- if (len < 1.0 && len > 0.01)
- return ret / len;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement