Py5Vector.set_mag_sq()#

Set the vector’s squared magnitude.

Examples#

 1v1 = py5.Py5Vector(3, 4)
 2
 3print("magnitude =", v1.mag)
 4# magnitude = 5.0
 5print("magnitude squared =", v1.mag_sq)
 6# magnitude squared = 25.0
 7
 8v1.set_mag_sq(100)
 9
10print("magnitude =", v1.mag)
11# magnitude = 10.0
12print("magnitude squared =", v1.mag_sq)
13# 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

Parameters#

  • mag_sq: float - vector magnitude squared

Updated on January 16, 2022 16:51:21pm UTC