isFlatEmpty: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (template:command argument fix)
(18 intermediate revisions by 3 users not shown)
Line 7: Line 7:
____________________________________________________________________________________________
____________________________________________________________________________________________


| Check if given area is flat and empty. |= Description
| Checks given position against given filter params. Filter includes checks for:
* If there are any objects closer than given distance from given position (in 2D)
* If the area around position is flat enough to match given gradient
* If the given position is over water or land
* If the given position is over shore line
The gradient seems to correlate with general hill steepness: 0.1 (10%) ~6<sup>o</sup>, 0.5 (50%) ~27<sup>o</sup>, 1.0 (100%) ~45<sup>o</sup>, etc.There are also some oddities about this command that need to be noted:
* Objects accounted for proximity check seem to be static objects. Nearby vehicles and units do not seem to affect the output
* Given position will be magically transferred into given position + [[getTerrainHeightASL]] value
* The second element must be -1 (<nowiki><=</nowiki> 0 really) at all times, otherwise command becomes unusable
* The command might be a bit heavy on computations so avoid frequent and large area checks
<br>See also: [[BIS_fnc_findSafePos]]
|DESCRIPTION=
____________________________________________________________________________________________
____________________________________________________________________________________________


| position '''isFlatEmpty''' [float minDistance,float precizePos,float maxGradient,float gradientRadius,float onWater,bool onShore,object skipobj] |= Syntax
| position '''isFlatEmpty''' [minDistance, mode, maxGradient, maxGradientRadius, overLandOrWater, shoreLine, ignoreObject] |SYNTAX=


|p1= position: [[Array]] - |= PARAMETER1
|p1= position: [[Array]] - position in format [[PositionAGL]]|PARAMETER1=  


|p2= [float minDistance,float precizePos,float maxGradient,float gradientRadius,float onWater,bool onShore,object skipobj]: [[Array]] |= PARAMETER2
|p2= [minDistance, mode, maxGradient, maxGradientRadius, overLandOrWater, shoreLine, ignoreObject]: [[Array]]|PARAMETER2=  


|p3= |= PARAMETER3
|p3= minDistance (Optional): [[Number]] - Objects within 50m cannot be closer than minDistance. -1 to ignore proximity check. Default: -1 |PARAMETER3=  


| [[Array]] |= RETURNVALUE
|p4= mode (Optional): [[Number]] - Position check mode (<b>ALWAYS USE DEFAULT VALUE!</b>). Default: -1 |PARAMETER4=


|p5= maxGradient (Optional): [[Number]] - Maximum terrain steepness allowed. -1 to ignore. Default: -1 |PARAMETER5=
|p6= maxGradientRadius (Optional): [[Number]] - How far to extend gradient check. Default: 1 |PARAMETER6=
|p7= overLandOrWater (Optional): [[Number]] -  0: position cannot be over water; 2: position cannot be over land. -1 to ignore. Default: 0 |PARAMETER6=
|p8= shoreLine (Optional): [[Boolean]] - [[true]]: position is over shoreline (< ~25 m from water). [[false]] to ignore. Default: [[false]] |PARAMETER6=
|p9= ignoreObject (Optional): [[Object]] - Object to ignore in proximity checks. [[objNull]] to ignore. Default: [[objNull]] |PARAMETER6=
| [[Array]] - Empty array [] if check failed or [[PositionASL]] if succeded. Resulting position will be original [[PositionAGL]] + [[getTerrainHeightASL]] |RETURNVALUE=
|x1=Check if player position is over land:<code>_overLand = !([[position]] [[player]] [[isFlatEmpty]] [-1, -1, -1, -1, 0, [[false]]] [[isEqualTo]] []);</code> |EXAMPLE1=
|x2=Check if player position is over shore line:<code>_overShore = !([[position]] [[player]] [[isFlatEmpty]]  [-1, -1, -1, -1, 0, [[true]]] [[isEqualTo]] []);</code> |EXAMPLE2=
|x3=Check if player position is over water:<code>_overWater = !([[position]] [[player]] [[isFlatEmpty]]  [-1, -1, -1, -1, 2, [[false]]] [[isEqualTo]] []);</code> |EXAMPLE3=
|x4=Check if no object is closer than 5m to player position:<code>_isEmpty = !([[position]] [[player]] [[isFlatEmpty]]  [5, -1, -1, -1, -1, [[false]], [[player]]] [[isEqualTo]] []);</code> |EXAMPLE4=
|x5=Check if area 10m around player position is relatively flat:<code>_isFlat = !([[position]] [[player]] [[isFlatEmpty]]  [-1, -1, 0.3, 10, -1] [[isEqualTo]] []);</code> |EXAMPLE5=
|x6=Check if area 15m around player position is very flat and empty:<code>_isFlatEmpty = !([[position]] [[player]] [[isFlatEmpty]]  [15, -1, 0.1, 15, -1, [[false]], [[player]]] [[isEqualTo]] []);</code> |EXAMPLE6=


|x1= <pre>_isFlat = (position _preview) isflatempty [
(sizeof typeof _preview) / 2, //--- Minimal distance from another object
0, //--- If 0, just check position. If >0, select new one
0.7, //--- Max gradient
(sizeof typeof _preview), //--- Gradient area
0, //--- 0 for restricted water, 2 for required water,
false, //--- True if some water can be in 25m radius
_preview //--- Ignored object
];</pre>|= EXAMPLE1


____________________________________________________________________________________________
____________________________________________________________________________________________


| [[selectBestPlaces]], [[findEmptyPosition]] |= SEEALSO
| [[selectBestPlaces]], [[findEmptyPosition]] |SEEALSO=  


|  |= MPBEHAVIOUR
|  |MPBEHAVIOUR=  
____________________________________________________________________________________________
____________________________________________________________________________________________
}}
}}
Line 41: Line 59:
<h3 style='display:none'>Notes</h3>
<h3 style='display:none'>Notes</h3>
<dl class='command_description'>
<dl class='command_description'>
<!-- Note Section BEGIN -->
<dd class="notedate">Posted on september 12, 2010 - 12:09 (CEST)
<dt class="note">'''[[User:Lou Montana|Lou Montana]]'''
<dd class="note">The returned pos is '''ASL'''. Use [[setPosASL]] or fly !
<dd class="notedate">Posted on april 15, 2013 - 20:12 (UTC)
<dt class="note">'''[[User:HELLinG3R|HELLinG3R]]'''
<dd class="note">isFlatEmpty returns an array holding a valid position or an empty array the check failed.
<!-- Note Section END -->
</dl>
</dl>


<h3 style='display:none'>Bottom Section</h3>
<h3 style='display:none'>Bottom Section</h3>
Line 63: Line 70:
<!-- CONTINUE Notes -->
<!-- CONTINUE Notes -->
<dl class="command_description">
<dl class="command_description">
<dd class="notedate">Posted on August 11, 2015 - 17:30 (UTC)</dd>
<dd class="notedate">Posted on April 24, 2016 - 17:18 (UTC)</dd>
<dt class="note">[[User:Gippo|Gippo]]</dt>
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
<dd class="note">
<dd class="note">
The '''onShore''' parameter on '''true''' only returned the array with position if I was near water (on shore).
When this command is instructed to check if area at given position is empty it takes into account the radius of the bounding sphere of surrounding objects. Because of this, the high voltage columns such as "Land_HighVoltageColumnWire_F" and such objects may appear extremely large to the calculations and the position will be rejected even if visually it doesn't look too bad. To avoid this, use [[findEmptyPosition]] command first to find guaranteed empty position, then pass the result to [[isFlatEmpty]] making sure you switched off proximity check by setting 1st param to -1. For example:
<code>// Check if given position is flat and empty within 1m radius
[4274.66,12113,0.00139618] [[isFlatEmpty]] [1, -1, 0.1, 1, -1, [[false]], [[objNull]]]; //[]</code>
The result suggests it is not flat and empty.
<code>// Check if given position is flat within 1m radius
[4274.66,12113,0.00139618] [[isFlatEmpty]] [-1, -1, 0.1, 1, -1, [[false]], [[objNull]]]; //[4274.66,12113,48.3209]</code>
The result suggests it is.
<code>// Check if given position is empty within 1m radius
[4274.66,12113,0.00139618] [[isFlatEmpty]] [1, -1, -1, -1, -1, [[false]], [[objNull]]]; //[]</code>
The result suggests it is not empty. But the position is in the middle of a road and there is nothing within 1m but there is "Land_HighVoltageColumnWire_F" not far.
<code>// Check if given position is empty within 1m radius ignoring nearest "Land_HighVoltageColumnWire_F"
[4274.66,12113,0.00139618] [[isFlatEmpty]] [1, -1, -1, 1, -1, [[false]], [[nearestObject]] [[4274.66,12113,0.00139618], "Land_HighVoltageColumnWire_F"]]; //[4274.66,12113,48.3209]</code>
The result now suggests it is empty. So instead of relying on internal proximity check we can combine both commands:
<code>fnc_isFlatEmpty =
{
[[params]] ["_pos", "_params"];
_pos = _pos [[findEmptyPosition]] [0, _params select 0];
[[if]] (_pos [[isEqualTo]] []) [[exitWith]] {[]};
_params =+ _params;
_params [[set]] [0, -1];
_pos = _pos [[isFlatEmpty]] _params;
[[if]] (_pos [[isEqualTo]] []) [[exitWith]] {[]};
_pos
};
 
// Test
[[4274.66,12113,0.00139618], [1, -1, 0.1, 1, -1, [[false]], [[objNull]]]] [[call]] fnc_isFlatEmpty; //[4274.53,12113,48.3175]
</code>
</dd>
</dd>
</dl>
</dl>
<!-- DISCONTINUE Notes -->
<!-- DISCONTINUE Notes -->

Revision as of 15:41, 7 April 2019

Hover & click on the images for description

Description

Description:
Checks given position against given filter params. Filter includes checks for:
  • If there are any objects closer than given distance from given position (in 2D)
  • If the area around position is flat enough to match given gradient
  • If the given position is over water or land
  • If the given position is over shore line
The gradient seems to correlate with general hill steepness: 0.1 (10%) ~6o, 0.5 (50%) ~27o, 1.0 (100%) ~45o, etc.There are also some oddities about this command that need to be noted:
  • Objects accounted for proximity check seem to be static objects. Nearby vehicles and units do not seem to affect the output
  • Given position will be magically transferred into given position + getTerrainHeightASL value
  • The second element must be -1 (<= 0 really) at all times, otherwise command becomes unusable
  • The command might be a bit heavy on computations so avoid frequent and large area checks

See also: BIS_fnc_findSafePos
Groups:
Uncategorised

Syntax

Syntax:
position isFlatEmpty [minDistance, mode, maxGradient, maxGradientRadius, overLandOrWater, shoreLine, ignoreObject]
Parameters:
position: Array - position in format PositionAGL
[minDistance, mode, maxGradient, maxGradientRadius, overLandOrWater, shoreLine, ignoreObject]: Array
minDistance (Optional): Number - Objects within 50m cannot be closer than minDistance. -1 to ignore proximity check. Default: -1
mode (Optional): Number - Position check mode (ALWAYS USE DEFAULT VALUE!). Default: -1
maxGradient (Optional): Number - Maximum terrain steepness allowed. -1 to ignore. Default: -1
maxGradientRadius (Optional): Number - How far to extend gradient check. Default: 1
overLandOrWater (Optional): Number - 0: position cannot be over water; 2: position cannot be over land. -1 to ignore. Default: 0
shoreLine (Optional): Boolean - true: position is over shoreline (< ~25 m from water). false to ignore. Default: false
ignoreObject (Optional): Object - Object to ignore in proximity checks. objNull to ignore. Default: objNull
Return Value:
Array - Empty array [] if check failed or PositionASL if succeded. Resulting position will be original PositionAGL + getTerrainHeightASL

Examples

Example 1:
Check if player position is over land:_overLand = !(position player isFlatEmpty [-1, -1, -1, -1, 0, false] isEqualTo []);
Example 2:
Check if player position is over shore line:_overShore = !(position player isFlatEmpty [-1, -1, -1, -1, 0, true] isEqualTo []);
Example 3:
Check if player position is over water:_overWater = !(position player isFlatEmpty [-1, -1, -1, -1, 2, false] isEqualTo []);
Example 4:
Check if no object is closer than 5m to player position:_isEmpty = !(position player isFlatEmpty [5, -1, -1, -1, -1, false, player] isEqualTo []);
Example 5:
Check if area 10m around player position is relatively flat:_isFlat = !(position player isFlatEmpty [-1, -1, 0.3, 10, -1] isEqualTo []);
Example 6:
Check if area 15m around player position is very flat and empty:_isFlatEmpty = !(position player isFlatEmpty [15, -1, 0.1, 15, -1, false, player] isEqualTo []);

Additional Information

See also:
selectBestPlacesfindEmptyPosition

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

Posted on April 24, 2016 - 17:18 (UTC)
Killzone Kid
When this command is instructed to check if area at given position is empty it takes into account the radius of the bounding sphere of surrounding objects. Because of this, the high voltage columns such as "Land_HighVoltageColumnWire_F" and such objects may appear extremely large to the calculations and the position will be rejected even if visually it doesn't look too bad. To avoid this, use findEmptyPosition command first to find guaranteed empty position, then pass the result to isFlatEmpty making sure you switched off proximity check by setting 1st param to -1. For example: // Check if given position is flat and empty within 1m radius [4274.66,12113,0.00139618] isFlatEmpty [1, -1, 0.1, 1, -1, false, objNull]; //[] The result suggests it is not flat and empty. // Check if given position is flat within 1m radius [4274.66,12113,0.00139618] isFlatEmpty [-1, -1, 0.1, 1, -1, false, objNull]; //[4274.66,12113,48.3209] The result suggests it is. // Check if given position is empty within 1m radius [4274.66,12113,0.00139618] isFlatEmpty [1, -1, -1, -1, -1, false, objNull]; //[] The result suggests it is not empty. But the position is in the middle of a road and there is nothing within 1m but there is "Land_HighVoltageColumnWire_F" not far. // Check if given position is empty within 1m radius ignoring nearest "Land_HighVoltageColumnWire_F" [4274.66,12113,0.00139618] isFlatEmpty [1, -1, -1, 1, -1, false, nearestObject [[4274.66,12113,0.00139618], "Land_HighVoltageColumnWire_F"]]; //[4274.66,12113,48.3209] The result now suggests it is empty. So instead of relying on internal proximity check we can combine both commands: fnc_isFlatEmpty = { params ["_pos", "_params"]; _pos = _pos findEmptyPosition [0, _params select 0]; if (_pos isEqualTo []) exitWith {[]}; _params =+ _params; _params set [0, -1]; _pos = _pos isFlatEmpty _params; if (_pos isEqualTo []) exitWith {[]}; _pos }; // Test [[4274.66,12113,0.00139618], [1, -1, 0.1, 1, -1, false, objNull]] call fnc_isFlatEmpty; //[4274.53,12113,48.3175]