Py5Vector.set_mag_sq()
Contents
Py5Vector.set_mag_sq()¶
Set the vector’s squared magnitude.
Examples¶
1 2 3 4 5 6 7 8 9 10 11 12 13 | v1 = py5.Py5Vector(3, 4)
print("magnitude =", v1.mag)
# magnitude = 5.0
print("magnitude squared =", v1.mag_sq)
# magnitude squared = 25.0
v1.set_mag_sq(100)
print("magnitude =", v1.mag)
# magnitude = 10.0
print("magnitude squared =", v1.mag_sq)
# magnitude squared = 100.0
|
Description¶
Set the vector’s squared magnitude. Setting this to a non-negative number will adjust the vector’s squared magnitude to that value. Negative values will result in an error.
Syntax¶
set_mag_sq(mag_sq: float) -> Py5Vector