If this vec3 is non-zero, then normalize it, else return
| 245 | |
| 246 | //! If this vec3 is non-zero, then normalize it, else return |
| 247 | inline void normalizeIfNonzero() { |
| 248 | const T l = length(); |
| 249 | if (l == static_cast<T>(0)) { return; } // Better to check against epsilon tolerance |
| 250 | const T val = static_cast<T>(1) / l; |
| 251 | array[0] *= val; |
| 252 | array[1] *= val; |
| 253 | array[2] *= val; |
| 254 | } |
| 255 | |
| 256 | inline vec3<T> getNormalized() const { |
| 257 | T val = (T) 1.0 / length(); |