Reference setMag()

setMag()

Sets a vector's magnitude to a given value.

The static version of setMag(), as in p5.Vector.setMag(v, 10), returns a new p5.Vector object and doesn't change the original.

Examples

Syntax

setMag(len)

Parameters

len
Number: new length for this vector.

Related References