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, Pmag is a shortcut for writing 0 0 x y Pdist. It is exactly the same as warpscript function HYPOT.

3D is not yet supported.

Link to original Processing doc

Pmag is available since version 1.0.0.

See also



// @preview image 100 100 '2D2' PGraphics 255 Pbackground 0 Pfill 30 'x' STORE //change me 40 'y' STORE //change me 0 0 $x $y Pline $x $y Pmag TOSTRING 50 50 Ptext $x $y HYPOT TOSTRING 50 70 Ptext Pencode