Calculates the magnitude, or length, of a vector.
A vector can be thought of in different ways. In one view, a vector is a point in space. The vector's components, x and y, are the point's coordinates (x, y). A vector's magnitude is the distance from the origin (0, 0) to (x, y). mag(x, y) is a shortcut for calling dist(0, 0, x, y).
A vector can also be thought of as an arrow pointing in space. This view is helpful for programming motion. See p5.Vector for more details.
Use p5.Vector.mag() to calculate the magnitude of a p5.Vector object.
Examples
Syntax
  
      mag(x, y)
      
         
      
    
Parameters
x
Number: 
first component.
y
Number: 
second component.
Returns
Number: magnitude of vector.
This page is generated from the comments in src/math/calculation.js . Please feel free to edit it and submit a pull request!