MCPcopy Create free account
hub / github.com/RozDavid/UnScene3D / normalizeIfNonzero

Method normalizeIfNonzero

utils/cpp_utils/include/vec3.h:247–254  ·  view source on GitHub ↗

If this vec3 is non-zero, then normalize it, else return

Source from the content-addressed store, hash-verified

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();

Callers

nothing calls this directly

Calls 1

lengthFunction · 0.85

Tested by

no test coverage detected