distanceSqr: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "Link\|https:\/\/en\.wikipedia\.org\/([^w][^i])" to "Link|https://en.wikipedia.org/wiki/$1")
No edit summary
Line 15: Line 15:


|r1= [[Number]] Distance in meters or 1e10 if distance cannot be calculated
|r1= [[Number]] Distance in meters or 1e10 if distance cannot be calculated
|r2= [[Number]] - distance in meters or 1e10 if distance cannot be calculated
|s2= a [[distanceSqr]] b
|s2since= arma3 2.16
|p21= a: [[Number]]
|p22= b: [[Number]]
|r2= [[Number]] - distance c calculated as c = a * a + b * b;


|x1= <sqf>player distanceSqr (leader player);</sqf>
|x1= <sqf>player distanceSqr (leader player);</sqf>

Revision as of 10:21, 26 October 2023

Hover & click on the images for description

Description

Description:
Computes the squared distance between two objects or positions.
Groups:
Math - Geometry

Syntax

Syntax:
var1 distanceSqr var2
Parameters:
var1: Object or Position
var2: Object or Position
Return Value:
Number Distance in meters or 1e10 if distance cannot be calculated

Alternative Syntax

Syntax:
a distanceSqr b
Parameters:
a: Number
b: Number
Return Value:
Number - distance c calculated as c = a * a + b * b;

Examples

Example 1:
player distanceSqr (leader player);
Example 2:
_distance = sqrt ((x2 - x1) ^ 2 + (y2 - y1) ^ 2 + (z2 - z1) ^ 2); _distanceSqr = (x2 - x1) ^ 2 + (y2 - y1) ^ 2 + (z2 - z1) ^ 2; _distance = [x1, y1, z1] distance [x2, y2, z2]; _distanceSqr = [x1, y1, z1] distanceSqr [x2, y2, z2]; _distance = sqrt ([x1, y1, z1] distanceSqr [x2, y2, z2]); _distanceSqr = ([x1, y1, z1] distance [x2, y2, z2]) ^ 2;

Additional Information

See also:
distance vectorDistanceSqr distance2D

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note