distanceSqr: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (return value & format)
m (template:command argument fix)
Line 12: Line 12:
| var1 '''distanceSqr''' var2 |= Syntax
| var1 '''distanceSqr''' var2 |= Syntax


|p1= var1: [[Object]] or [[Position]]  |= PARAMETER1
|p1= var1: [[Object]] or [[Position]]  |PARAMETER1=  


|p2= var2: [[Object]] or [[Position]]  |= PARAMETER2
|p2= var2: [[Object]] or [[Position]]  |PARAMETER2=  


| [[Number]] Distance in meters or 1e10 if distance cannot be calculated |= RETURNVALUE
| [[Number]] Distance in meters or 1e10 if distance cannot be calculated |RETURNVALUE=  




|x1= <code>[[player]] [[distanceSqr]] ([[leader]] [[player]])</code>|= EXAMPLE1
|x1= <code>[[player]] [[distanceSqr]] ([[leader]] [[player]])</code>|EXAMPLE1=  


|x2= <code>_distance = [[sqrt]] ((x2 - x1) ^ 2 + (y2 - y1) ^ 2 + (z2 - z1) ^ 2);
|x2= <code>_distance = [[sqrt]] ((x2 - x1) ^ 2 + (y2 - y1) ^ 2 + (z2 - z1) ^ 2);
Line 26: Line 26:
_distanceSqr = [x1, y1, z1] [[distanceSqr]] [x2, y2, z2];
_distanceSqr = [x1, y1, z1] [[distanceSqr]] [x2, y2, z2];
_distance = [[sqrt]] ([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;</code>|= EXAMPLE2
_distanceSqr = ([x1, y1, z1] [[distance]] [x2, y2, z2]) ^ 2;</code>|EXAMPLE2=


If normal distance is calculated according to this formula:
If normal distance is calculated according to this formula:
Line 37: Line 37:
____________________________________________________________________________________________
____________________________________________________________________________________________


| [[distance]], [[vectorDistanceSqr]], [[distance2D]] |= SEEALSO
| [[distance]], [[vectorDistanceSqr]], [[distance2D]] |SEEALSO=  


|  |= MPBEHAVIOUR
|  |MPBEHAVIOUR=  
____________________________________________________________________________________________
____________________________________________________________________________________________
}}
}}

Revision as of 11:30, 7 April 2019

Hover & click on the images for description

Description

Description:
Computes the squared distance between two objects or positions.
Groups:
Uncategorised

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

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:
distancevectorDistanceSqrdistance2D

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

Notes

Bottom Section