MCPcopy Index your code
hub / github.com/processing/p5.js / normalize

Method normalize

src/math/p5.Vector.js:1658–1664  ·  view source on GitHub ↗

* Scales the components of a p5.Vector object so * that its magnitude is 1. * * The static version of `normalize()`, as in `p5.Vector.normalize(v)`, * returns a new p5.Vector object and doesn't change * the original. * * @retu

()

Source from the content-addressed store, hash-verified

1656 * }
1657 */
1658 normalize() {
1659 const len = this.mag();
1660 // here we multiply by the reciprocal instead of calling 'div()'
1661 // since div duplicates this zero check.
1662 if (len !== 0) this.mult(1 / len);
1663 return this;
1664 }
1665
1666 /**
1667 * Limits a vector's magnitude to a maximum value.

Callers 15

setMagMethod · 0.95
attractor.jsFile · 0.45
seekMethod · 0.45
separateMethod · 0.45
alignMethod · 0.45
liquid.jsFile · 0.45
p5.Shader.jsFile · 0.45
p5.Shader.jsFile · 0.45
fresnelShaderCallbackFunction · 0.45
webgl.jsFile · 0.45
fresnelShaderCallbackFunction · 0.45
p5.Vector.jsFile · 0.45

Calls 5

magMethod · 0.95
multMethod · 0.95
_friendlyErrorMethod · 0.95
copyMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected