Arma 3 Scripting

vectorFromTo

  • Arma 3 v1.26

Command · Markdown · JSON · original wiki page

Description

Unit vector, equal to direction from vector1 to vector2. In other words this command produces normalised vector between given 2 points.
To get a non-normalised vector, use vectorDiff.

Syntax

vector1 vectorFromTo vector2

Parameters:

Returns: Vector3D

Examples

Example 1

[1,2,3] vectorFromTo [4,5,6];
// is the same as
vectorNormalized ([4,5,6] vectorDiff [1,2,3]);

See also

vectorDiff · vectorCrossProduct · vectorDotProduct · vectorCos · vectorMagnitude · vectorMagnitudeSqr · vectorMultiply · vectorDistance · vectorDistanceSqr · vectorDir · vectorUp · setVectorDir · setVectorUp · setVectorDirAndUp · vectorNormalized · matrixMultiply · matrixTranspose

Community notes

ffur2007slx2_5

Arma 3 v1.26 Algorithm:

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