MIST getRandPointInCircle
mist.getRandPointInCircle
Added with: Mist 2.0 |
Description |
Returns a randomly generated vec2 coordinate within the specified radius around the center of vec 2 or vec3 point given. If the optional variable innerRadius is given the random point will be generated that has a minimum distance of innerRadius and a maximum distance of radius from the point.
The optional values maxA and minA can be used to limit the possible area of a circle that the random point is returned within. Think of a pizza slice or Pacman as the shape that can be returned. maxA and minA are defined in degrees. These values can be any number, however it is important to realize that they are used to generate a random point in a circle. maxA set to 540 for instance would simply result in a higher probability of the point returning in the right half of the circle compared to the left half. maxA is optional. If not present then it assumes the shape is a circle. minA is optional. If not present then the range will assume minA is 0 (North) to whatever maxA is set to if present. |
Syntax |
vec2 mist.getRandPointInCircle(table vec2/vec3 ,number radius , number innerRadius ,number maxA ,number minA ) |
Valid Input Values: |
vec2/vec3 = valid vec2/3 table
radius = any positive number innerRadius = any positive number less than radius maxA = A number in degrees with 0 being North minA = A number in degrees. Should be smaller than maxA value. |
Return value: |
vec2 |
Return example: |
Template:Vec2 |
Usage Examples: |
The following code will deploy a smoke marker randomly inside a zone.
local u = Unit.getByName('whatever') local headingDeg = math.deg(mist.getHeading(u, true)) local newPoint = mist.getRandPointInCircle(u:getPoint(), 20000, 10000, headingDeg + 90, headingDeg - 90) |
Notes: |
Used within: groupToRandomZone, groupRandomDistSelf, groupToRandomPoint |
Related Functions |
makeUnitTable, getRandPointInCircle, getRandomPointInZone, isTerrainValid, terrainHeightDiff, getUnitsInZones, getUnitsInMovingZones, pointInPolygon, getUnitsInPolygon, getDeadMapObjsInZones, getDeadMapObjsInPolygonZone, getUnitsLOS, random, randomizeNumTable, getAvgPoint, getQFE, getWindBearingAndVel, getPathLength, getPathInSegments, getPointAtDistanceOnPath, projectPoint, getGroupsByAttribute, , getUnitsByAttribute, mapValue, |