mag(x, y, [z])

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 coordinate (0,0) to its (x,y) value. Therefore, mag() is a shortcut for writing dist(0, 0, x, y).

Type: function

Parameter(s):

  • x {Number}:

    Coordinate.

  • y {Number}:

    Coordinate.

  • z {Number} Optional:

    Coordinate, optional.

Returns:

  • {Number}:

    The magnitude.