Loading

Pdist


processing
Since v1.0.0
Available on all platforms

Calculates the distance between two points, in 2D or 3D space.

Link to original Processing doc

Signature

Examples

// @preview image 200 100 '2D2' PGraphics 255 Pbackground 0 Pfill //random points. Print the distance between points in px RAND 30 * 'x1' STORE RAND 30 * 'y1' STORE RAND 30 * 70 + 'x2' STORE RAND 30 * 50 + 'y2' STORE $x1 $y1 $x2 $y2 Pline $x1 $y1 $x2 $y2 Pdist TOSTRING 110 20 Ptext Pencode $x1 $x2 - $y1 $y2 - HYPOT // this Warp 10 function does the same for 2D