l2Distance.php
Table of Contents
Functions
- l2Distance() : string
- Return the L2 (Euclidean) distance between two vectors.
Functions
l2Distance()
Return the L2 (Euclidean) distance between two vectors.
l2Distance(string|int $x, string|int $y) : string
This helper wraps the ArangoDB AQL function L2_DISTANCE(x, y) which
calculates the straight-line distance between two equally-sized numeric
vectors (the square root of the sum of the squared component differences).
The smaller the value, the closer the vectors are.
Unlike approxNearL2(), this computes the exact distance and does not require (nor benefit from) a vector index.
Example AQL usage:
L2_DISTANCE([1, 2], [4, 6]) // returns 5 (sqrt(3² + 4²))
L2_DISTANCE([0, 0], [0, 0]) // returns 0 (identical vectors)
Parameters
- $x : string|int
-
First input array (vector).
- $y : string|int
-
Second input array (vector).
Tags
Return values
string —The formatted AQL expression.