distanceSqr: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "_{10,} " to "") |
Lou Montana (talk | contribs) m (Text replacement - " *\| *([Cc]omments|COMMENTS|Game|[Gg]ame [Nn]ame|Game [Vv]ersion|Game Version \(number surrounded by NO SPACES\)|Multiplayer Arguments( \("local" or "global"\))?|Effects|Multiplayer Effects( \("local" or "global"\))?|Multiplayer Exe...) |
||
Line 1: | Line 1: | ||
{{Command | {{Command | ||
| arma3 | | arma3 | ||
|0.50 | |0.50 | ||
|gr1= Math - Geometry | |gr1= Math - Geometry | ||
| Computes the [http://en.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance squared distance] between two objects or positions. | | Computes the [http://en.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance squared distance] between two objects or positions. | ||
| var1 '''distanceSqr''' var2 | | var1 '''distanceSqr''' var2 | ||
|p1= var1: [[Object]] or [[Position]] | |p1= var1: [[Object]] or [[Position]] | ||
|p2= var2: [[Object]] or [[Position]] | |p2= var2: [[Object]] or [[Position]] | ||
| [[Number]] Distance in meters or 1e10 if distance cannot be calculated | | [[Number]] Distance in meters or 1e10 if distance cannot be calculated | ||
|x1= <code>[[player]] [[distanceSqr]] ([[leader]] [[player]])</code> | |x1= <code>[[player]] [[distanceSqr]] ([[leader]] [[player]])</code> | ||
|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 25: | Line 25: | ||
_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> | _distanceSqr = ([x1, y1, z1] [[distance]] [x2, y2, z2]) ^ 2;</code> | ||
If normal distance is calculated according to this formula: | If normal distance is calculated according to this formula: | ||
Line 35: | Line 35: | ||
| [[distance]], [[vectorDistanceSqr]], [[distance2D]] | | [[distance]], [[vectorDistanceSqr]], [[distance2D]] | ||
| |MPBEHAVIOUR= | | |MPBEHAVIOUR= |
Revision as of 00:27, 18 January 2021
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
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;
If normal distance is calculated according to this formula: squared distance is calculated according to this formula: distanceSqr =
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