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

Method clampLength

src/engineMath.js:707–711  ·  view source on GitHub ↗

Returns a new vector clamped to length passed in * @param {number} [length] * @return {Vector2}

(length=1)

Source from the content-addressed store, hash-verified

705 * @param {number} [length]
706 * @return {Vector2} */
707 clampLength(length=1)
708 {
709 const l = this.length();
710 return l > length ? this.scale(length/l) : this.copy();
711 }
712
713 /** Returns the dot product of this and the vector passed in
714 * @param {Vector2} v - other vector

Callers 6

math.test.mjsFile · 0.80
handleTouchGamepadFunction · 0.80
applyDeadZonesFunction · 0.80
gamepadsUpdateFunction · 0.80
updateMethod · 0.80
updateMethod · 0.80

Calls 3

lengthMethod · 0.95
scaleMethod · 0.95
copyMethod · 0.95

Tested by

no test coverage detected