inPolygon: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\{\{GameCategory\|(arma[0123])\|[ _]?New[ _]Scripting[ _]Commands[ _]List\}\}" to "{{GameCategory|$1|New Scripting Commands}}")
No edit summary
 
(26 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Command|Comments=
{{RV|type=command
____________________________________________________________________________________________


| arma3 |Game name=
|game1= arma3
|version1= 1.54


|1.54|Game version=
|gr1= Positions


|gr1= Positions |GROUP1=
|descr= Checks whether position is inside given polygon. The polygon is only checked in 2 dimensions, i.e. the value of Z is ignored.
____________________________________________________________________________________________


| Checks whether position is inside given polygon |DESCRIPTION=
|s1= position [[inPolygon]] polygon
____________________________________________________________________________________________


| position '''inPolygon''' polygon |SYNTAX=
|p1= position: [[Array]] format [[Position#Introduction|Position3D]], {{GVI|arma3|2.14|size= 0.75}} [[Object]] or [[Group]]
|p1= position: [[Array]] - format [[Position3D]] |PARAMETER1=
|p2= polygon: [[Array]] - array of [[Position3D]] positions in format: [position1, position2...., positionN] |PARAMETER2=


| [[Boolean]] |RETURNVALUE=
|p2= polygon: [[Array]] of [[Position#Introduction|Position3D]] - positions in format: [position1, position2...., positionN]
____________________________________________________________________________________________


|x1= <code>_isInside = [100,100,0] [[inPolygon]] [[0,0,0],[1000,1000,0],[1000,0,0]];</code>|=
|r1= [[Boolean]]
|[[in]], [[inArea]], [[drawPolygon]]  |SEEALSO=


}}
|x1= <sqf>private _isInside = [100, 100, 0] inPolygon [[0, 0, 0], [1000, 1000, 0], [1000, 0, 0]];</sqf>
 
|x2= <sqf>
private _markerName = "_USER_DEFINED #0/0/1";
 
private _xy2DPositions = markerPolyline _markerName;
private _positions = [];
 
// let's convert these x,y coordinates to "normal" position arrays
for "_i" from 0 to count _xy2DPositions - 1 step 2 do
{
_positions pushBack [_xy2DPositions select _i, _xy2DPositions select (_i + 1), 0];
};


<h3 style="display:none">Notes</h3>
player inPolygon _positions; // true if in the drawn shape, false if not
<dl class="command_description">
</sqf>
</dl>


<h3 style="display:none">Bottom Section</h3>
|seealso= [[in]] [[inArea]] [[inAreaArray]] [[drawPolygon]]
{{GameCategory|arma3|New Scripting Commands}}
}}
{{GameCategory|arma3|Scripting Commands}}
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]

Latest revision as of 08:54, 7 November 2024

Hover & click on the images for description

Description

Description:
Checks whether position is inside given polygon. The polygon is only checked in 2 dimensions, i.e. the value of Z is ignored.
Groups:
Positions

Syntax

Syntax:
position inPolygon polygon
Parameters:
position: Array format Position3D, Arma 3 logo black.png2.14 Object or Group
polygon: Array of Position3D - positions in format: [position1, position2...., positionN]
Return Value:
Boolean

Examples

Example 1:
private _isInside = [100, 100, 0] inPolygon [[0, 0, 0], [1000, 1000, 0], [1000, 0, 0]];
Example 2:
private _markerName = "_USER_DEFINED #0/0/1"; private _xy2DPositions = markerPolyline _markerName; private _positions = []; // let's convert these x,y coordinates to "normal" position arrays for "_i" from 0 to count _xy2DPositions - 1 step 2 do { _positions pushBack [_xy2DPositions select _i, _xy2DPositions select (_i + 1), 0]; }; player inPolygon _positions; // true if in the drawn shape, false if not

Additional Information

See also:
in inArea inAreaArray drawPolygon

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