mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
add "inner" and "outer" parameter to ZONE_RADIUS:GetRandomVec2() method
This commit is contained in:
parent
e00e3104ab
commit
ac7dd8cb2f
@ -449,16 +449,20 @@ end
|
|||||||
|
|
||||||
--- Returns a random location within the zone.
|
--- Returns a random location within the zone.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
|
-- @param #number inner minimal distance from the center of the zone
|
||||||
|
-- @param #number outer minimal distance from the outer edge of the zone
|
||||||
-- @return Dcs.DCSTypes#Vec2 The random location within the zone.
|
-- @return Dcs.DCSTypes#Vec2 The random location within the zone.
|
||||||
function ZONE_RADIUS:GetRandomVec2()
|
function ZONE_RADIUS:GetRandomVec2(inner, outer)
|
||||||
self:F( self.ZoneName )
|
self:F( self.ZoneName, inner, outer )
|
||||||
|
|
||||||
local Point = {}
|
local Point = {}
|
||||||
local Vec2 = self:GetVec2()
|
local Vec2 = self:GetVec2()
|
||||||
|
local _inner = inner or 0
|
||||||
|
local _outer = outer or self:GetRadius()
|
||||||
|
|
||||||
local angle = math.random() * math.pi*2;
|
local angle = math.random() * math.pi * 2;
|
||||||
Point.x = Vec2.x + math.cos( angle ) * math.random() * self:GetRadius();
|
Point.x = Vec2.x + math.cos( angle ) * math.random(_inner, _outer);
|
||||||
Point.y = Vec2.y + math.sin( angle ) * math.random() * self:GetRadius();
|
Point.y = Vec2.y + math.sin( angle ) * math.random(_inner, _outer);
|
||||||
|
|
||||||
self:T( { Point } )
|
self:T( { Point } )
|
||||||
|
|
||||||
|
|||||||
@ -6321,16 +6321,20 @@ end
|
|||||||
|
|
||||||
--- Returns a random location within the zone.
|
--- Returns a random location within the zone.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
|
-- @param #number inner minimal distance from the center of the zone
|
||||||
|
-- @param #number outer minimal distance from the outer edge of the zone
|
||||||
-- @return Dcs.DCSTypes#Vec2 The random location within the zone.
|
-- @return Dcs.DCSTypes#Vec2 The random location within the zone.
|
||||||
function ZONE_RADIUS:GetRandomVec2()
|
function ZONE_RADIUS:GetRandomVec2(inner, outer)
|
||||||
self:F( self.ZoneName )
|
self:F( self.ZoneName, inner, outer )
|
||||||
|
|
||||||
local Point = {}
|
local Point = {}
|
||||||
local Vec2 = self:GetVec2()
|
local Vec2 = self:GetVec2()
|
||||||
|
local _inner = inner or 0
|
||||||
|
local _outer = outer or self:GetRadius()
|
||||||
|
|
||||||
local angle = math.random() * math.pi*2;
|
local angle = math.random() * math.pi * 2;
|
||||||
Point.x = Vec2.x + math.cos( angle ) * math.random() * self:GetRadius();
|
Point.x = Vec2.x + math.cos( angle ) * math.random(_inner, _outer);
|
||||||
Point.y = Vec2.y + math.sin( angle ) * math.random() * self:GetRadius();
|
Point.y = Vec2.y + math.sin( angle ) * math.random(_inner, _outer);
|
||||||
|
|
||||||
self:T( { Point } )
|
self:T( { Point } )
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user