Py5Vector.normalize()#

Normalize the vector by setting the vector’s magnitude to 1.0.

Examples#

1v1 = py5.Py5Vector(3, 4)
2
3print("magnitude =", v1.mag)
4# magnitude = 5.0
5
6v1.normalize()
7
8print("magnitude =", v1.mag)
9# magnitude = 1.0

Description#

Normalize the vector by setting the vector’s magnitude to 1.0. This method cannot be used on a vector of zeros, because a vector of zeros cannot be normalized.

Syntax#

normalize() -> Py5Vector

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