参考 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.

示例

语法

setMag(len)
setMag(v, len, [target])

参数

len
Number:

new length for this vector.

v
p5.Vector:

the vector to set the magnitude of

target
p5.Vector:

the vector to receive the result (Optional)

This page is generated from the comments in src/math/p5.Vector.js . Please feel free to edit it and submit a pull request!

相关参考