From e59caac2c77211f24b142460e8a7e5644b0609d9 Mon Sep 17 00:00:00 2001 From: Sven Van de Velde Date: Fri, 12 Aug 2016 09:06:50 +0200 Subject: [PATCH] Progress --- Moose Development/Moose/Point.lua | 42 +++++++++++++++---- Moose Development/Moose/Spawn.lua | 6 ++- .../Release Notes/2016-07 - ReleaseNotes.txt | 9 ++++ 3 files changed, 46 insertions(+), 11 deletions(-) diff --git a/Moose Development/Moose/Point.lua b/Moose Development/Moose/Point.lua index de49027cb..f34277a60 100644 --- a/Moose Development/Moose/Point.lua +++ b/Moose Development/Moose/Point.lua @@ -66,6 +66,19 @@ POINT_VEC3 = { }, } +--- The POINT_VEC2 class +-- @type POINT_VEC2 +-- @extends #POINT_VEC3 +-- @field DCSTypes#Distance x The x coordinate in meters. +-- @field DCSTypes#Distance y the y coordinate in meters. +POINT_VEC2 = { + ClassName = "POINT_VEC2", + x = 0, + y = 0, +} + + +do -- POINT_VEC3 --- SmokeColor -- @type POINT_VEC3.SmokeColor @@ -373,6 +386,20 @@ function POINT_VEC3:IsMetric() return self.Metric end +--- Add a Distance in meters from the POINT_VEC3 horizontal plane, with the given angle, and calculate the new POINT_VEC3. +-- @param #POINT_VEC3 self +-- @param DCSTypes#Distance Distance The Distance to be added in meters. +-- @param DCSTypes#Angle Angle The Angle in degrees. +-- @return #POINT_VEC3 The new calculated POINT_VEC3. +function POINT_VEC3:Translate( Distance, Angle ) + local SX = self:GetX() + local SZ = self:GetZ() + local Radians = Angle / 180 * math.pi + local TX = Distance * math.cos( Radians ) + SX + local TZ = Distance * math.sin( Radians ) + SZ + + return POINT_VEC3:New( TX, self:GetY(), TZ ) +end @@ -543,17 +570,13 @@ function POINT_VEC3:FlareRed( Azimuth ) self:Flare( POINT_VEC3.FlareColor.Red, Azimuth ) end +end ---- The POINT_VEC2 class --- @type POINT_VEC2 --- @extends Point#POINT_VEC3 --- @field #number x The x coordinate in 2D space. --- @field #number y the y coordinate in 2D space. -POINT_VEC2 = { - ClassName = "POINT_VEC2", - } +do -- POINT_VEC2 ---- Create a new POINT_VEC2 object. + + +--- POINT_VEC2 constructor. -- @param #POINT_VEC2 self -- @param DCSTypes#Distance x The x coordinate of the Vec3 point, pointing to the North. -- @param DCSTypes#Distance y The y coordinate of the Vec3 point, pointing to the Right. @@ -689,5 +712,6 @@ function POINT_VEC2:Translate( Distance, Angle ) return POINT_VEC2:New( TX, TY ) end +end diff --git a/Moose Development/Moose/Spawn.lua b/Moose Development/Moose/Spawn.lua index 09567bf63..455c93683 100644 --- a/Moose Development/Moose/Spawn.lua +++ b/Moose Development/Moose/Spawn.lua @@ -606,8 +606,10 @@ function SPAWN:SpawnFromVec3( Vec3, RandomizeUnits, OuterRadius, InnerRadius, Sp else for UnitID = 1, #SpawnTemplate.units do local UnitTemplate = SpawnTemplate.units[UnitID] - local UnitPointVec3 = POINT_VEC3:New( UnitTemplate.x, UnitTemplate.alt, UnitTemplate.y ) - UnitPointVec3 = UnitPointVec3: + local UnitPointVec2 = POINT_VEC2:New( UnitTemplate.x, UnitTemplate.y ) + local Distance = UnitPointVec2 + local Angle = UnitPointVec2:GetAngle( PointVec3 ) + UnitPointVec2 = UnitPointVec2:Translate( Distance, Angle ) local RandomVec2 = PointVec3:GetRandomVec2InRadius( OuterRadius, InnerRadius ) SpawnTemplate.units[UnitID].x = RandomVec2.x SpawnTemplate.units[UnitID].y = RandomVec2.y diff --git a/Moose Development/Release Notes/2016-07 - ReleaseNotes.txt b/Moose Development/Release Notes/2016-07 - ReleaseNotes.txt index 0a55ab167..041f42a70 100644 --- a/Moose Development/Release Notes/2016-07 - ReleaseNotes.txt +++ b/Moose Development/Release Notes/2016-07 - ReleaseNotes.txt @@ -2,6 +2,15 @@ - Temporary release of the new cargo handling. -- Released available functionality to handle one CARGO_UNIT loading, boarding, unloading. -- Created CARGO_UNIT test missions. + - Added Translate() method in POINT_VEC3, translating a 3D point over the horizontal plane with a Distance and Angle coordinate. + - Changed Spawn APIs, adding RandomizeGroup and RandomizeUnits parameters, to express Group position and Unit position randomization. + -- Changed SpawnInZone() method. + --- RandomizeGroup is used to randomize the start position of the Group in a zone. + --- RandomizeUnits is used to randomize the start position of the Units in a defined radius band, through OuterRadius and InnerRadius parameters. + -- Changed SpawnFromVec3() method. + --- RandomizeUnits is used to randomize the start position of the Units in a defined radius band, through OuterRadius and InnerRadius parameters. + -- Changed SpawnFromVec2() method. + --- RandomizeUnits is used to randomize the start position of the Units in a defined radius band, through OuterRadius and InnerRadius parameters. 2016-08-08 - Added briefing to method ESCORT:New()