Arma 3 Scripting

Command in Math - Vectors

vectorDistanceSqr

Also available as Markdown and JSON, or read the original wiki page.

Description

Squared distance between two 3D vectors.

Syntax

vector1 vectorDistanceSqr vector2

Parameters:

Returns: Number

Examples

Example 1

_distSqr = getPos player vectorDistanceSqr [0,0,2];

See also

vectorAdd · vectorDiff · vectorCrossProduct · vectorDotProduct · vectorCos · vectorMagnitude · vectorMagnitudeSqr · vectorMultiply · vectorDistance · vectorDir · vectorUp · setVectorDir · setVectorUp · setVectorDirAndUp · distanceSqr · vectorNormalized · vectorFromTo

Community notes

ffur2007slx2_5

Algorithm:

_vector1 = [x1,y1,z1];
_vector2 = [x2,y2,z2];
_result = (x2 - x1) ^ 2 + (y2 - y1) ^ 2 + (z2 - z1) ^ 2;