MCPcopy Create free account
hub / github.com/microsoft/SandDance / normalize

Function normalize

docs/tests/v2/es6/js/sanddance.js:16335–16348  ·  view source on GitHub ↗

* Normalize a vec2 * * @param {vec2} out the receiving vector * @param {vec2} a vector to normalize * @returns {vec2} out

(out, a)

Source from the content-addressed store, hash-verified

16333
16334
16335function normalize(out, a) {
16336 var x = a[0],
16337 y = a[1];
16338 var len = x * x + y * y;
16339
16340 if (len > 0) {
16341 //TODO: evaluate use of glm_invsqrt here?
16342 len = 1 / Math.sqrt(len);
16343 }
16344
16345 out[0] = a[0] * len;
16346 out[1] = a[1] * len;
16347 return out;
16348}
16349/**
16350 * Calculates the dot product of two vec2's
16351 *

Callers 5

angleFunction · 0.70
sanddance.jsFile · 0.70
_defaultFunction · 0.70
bimapFunction · 0.70
polymapFunction · 0.70

Calls 6

replaceMethod · 0.80
validateFunction · 0.70
getVertexCountFunction · 0.70
copyFlatRingFunction · 0.70
isSimpleFunction · 0.70
copyNestedRingFunction · 0.70

Tested by

no test coverage detected