x1 = 20
x2 = 80
y1 = 30
y2 = 70
line(0, 0, x1, y1)
print(mag(x1, y1))  # Prints "36.05551"
line(0, 0, x2, y1)
print(mag(x2, y1))  # Prints "85.44004"
line(0, 0, x1, y2)
print(mag(x1, y2))  # Prints "72.8011"
line(0, 0, x2, y2)
print(mag(x2, y2))  # Prints "106.30146"
Description Calculates the magnitude (or length) of a vector. A vector is a direction in space commonly used in computer graphics and linear algebra. Because it has no "start" position, the magnitude of a vector can be thought of as the distance from the coordinate 0,0 to its x,y value. Therefore, mag() is a shortcut for writing dist(0, 0, x, y).
mag(x, y)
xint: x component of a vector
yint: y component of a vector
Related magSq()

Updated on Tue Feb 27 14:07:12 2024.

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