mag()
Math / CalculationDescription
Calculates the magnitude (length) of a vector. Supports 2D and 3D.
Syntax
float mag(float x, float y)
float mag(float x, float y, float z)
Parameters
| Name | Type | Description |
|---|---|---|
| x | float | x component |
| y | float | y component |
| z | float | z component (optional) |
Returns
floatRelated
Under the Hood
From Processing.h:
float mag() const { return std::sqrt(x*x + y*y + z*z); }
static float mag(float x, float y) { return std::sqrt(x*x+y*y); }
static float mag(float x, float y, float z) { return std::sqrt(x*x+y*y+z*z); }