inPolygon: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "\|" to "|") |
BrettMayson (talk | contribs) mNo edit summary |
||
(13 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{RV|type=command | {{RV|type=command | ||
| arma3 | |game1= arma3 | ||
|version1= 1.54 | |||
| | |gr1= Positions | ||
|descr= Checks whether position is inside given polygon. The polygon is only checked in 2 dimensions, i.e. the value of Z is ignored. | |||
| | |s1= position [[inPolygon]] polygon | ||
| | |p1= position: [[Array]] format [[Position#Introduction|Position3D]], {{GVI|arma3|2.14|size= 0.75}} [[Object]] or [[Group]] | ||
|p2= polygon: [[Array]] of [[Position#Introduction|Position3D]] - positions in format: [position1, position2...., positionN] | |||
|p2= polygon: [[Array]] | |||
|r1= [[Boolean]] | |r1= [[Boolean]] | ||
|x1= < | |x1= <sqf>private _isInside = [100, 100, 0] inPolygon [[0, 0, 0], [1000, 1000, 0], [1000, 0, 0]];</sqf> | ||
|seealso= [[in]] | |||
|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]; | |||
}; | |||
player inPolygon _positions; // true if in the drawn shape, false if not | |||
</sqf> | |||
|seealso= [[in]] [[inArea]] [[drawPolygon]] | |||
}} | }} |
Latest revision as of 10:55, 28 September 2023
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, 2.14 Object or Group
- polygon: Array of Position3D - positions in format: [position1, position2...., positionN]
- Return Value:
- Boolean
Examples
- Example 1:
- 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 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