MCPcopy
hub / github.com/KilledByAPixel/LittleJS / normalize

Method normalize

src/engineMath.js:698–702  ·  view source on GitHub ↗

Returns a new vector in same direction as this one with the length passed in * @param {number} [length] * @return {Vector2}

(length=1)

Source from the content-addressed store, hash-verified

696 * @param {number} [length]
697 * @return {Vector2} */
698 normalize(length=1)
699 {
700 const l = this.length();
701 return l ? this.scale(length/l) : new Vector2(0, length);
702 }
703
704 /** Returns a new vector clamped to length passed in
705 * @param {number} [length]

Callers 10

math.test.mjsFile · 0.80
box2d.wasm.jsFile · 0.80
getHitOffsetMethod · 0.80
updateMethod · 0.80
gameRenderFunction · 0.80
collideWithObjectMethod · 0.80
collideWithObjectMethod · 0.80
explosionFunction · 0.80
explosionFunction · 0.80
updateMethod · 0.80

Calls 2

lengthMethod · 0.95
scaleMethod · 0.95

Tested by

no test coverage detected