Name

setMag()

Examples
v = PVector(3, 4, 0)
v.setMag(10)
print(v)  # Prints "[ 6.0, 8.0, 0.0 ]"
Description Set the magnitude of this vector to the value used for the len parameter.
Syntax
.setMag(len)
.setMag(target, len)
Parameters
lenfloat: the new length for this vector
targetPVector: Set to null to create a new vector
lenfloat: the new length for the new vector

Updated on Thu Oct 22 12:07:48 2026.

If you see any errors or have comments, please let us know.