diff --git a/Moose Development/Moose/Core/Point.lua b/Moose Development/Moose/Core/Point.lua index 9c6628980..0c63371ba 100644 --- a/Moose Development/Moose/Core/Point.lua +++ b/Moose Development/Moose/Core/Point.lua @@ -54,227 +54,114 @@ -- @module Point ---- @type COORDINATE --- @extends Core.Base#BASE ---- # COORDINATE class, extends @{Base#BASE} --- --- The COORDINATE class defines a 2D coordinate in the simulator. The height coordinate (if needed) will be the land height + an optional added height specified. --- A COORDINATE can be expressed in LL or in MGRS. --- --- ## COORDINATE constructor --- --- A new COORDINATE instance can be created with: --- --- * @{Point#COORDINATE.New}(): a 2D point, taking an additional height parameter. --- * @{Point#COORDINATE.NewFromVec2}(): a 2D point created from a @{DCSTypes#Vec2}. --- --- ## Manupulate the X, Altitude, Y coordinates of the 2D point --- --- A COORDINATE class works in 2D space, with an altitude setting. It contains internally an X, Altitude, Y coordinate. --- Methods exist to manupulate these coordinates. --- --- The current X, Altitude, Y axis can be retrieved with the methods @{#COORDINATE.GetX}(), @{#COORDINATE.GetAlt}(), @{#COORDINATE.GetY}() respectively. --- The methods @{#COORDINATE.SetX}(), @{#COORDINATE.SetAlt}(), @{#COORDINATE.SetY}() change the respective axis with a new value. --- The current Lat(itude), Alt(itude), Lon(gitude) values can also be retrieved with the methods @{#COORDINATE.GetLat}(), @{#COORDINATE.GetAlt}(), @{#COORDINATE.GetLon}() respectively. --- The current axis values can be changed by using the methods @{#COORDINATE.AddX}(), @{#COORDINATE.AddAlt}(), @{#COORDINATE.AddY}() --- to add or substract a value from the current respective axis value. --- Note that the Set and Add methods return the current COORDINATE object, so these manipulation methods can be chained... For example: --- --- local Vec2 = PointVec2:AddX( 100 ):AddY( 2000 ):GetVec2() --- --- @field #COORDINATE -COORDINATE = { - ClassName = "COORDINATE", -} - ---- The POINT_VEC3 class --- @type POINT_VEC3 --- @field #number x The x coordinate in 3D space. --- @field #number y The y coordinate in 3D space. --- @field #number z The z coordiante in 3D space. --- @field Utilities.Utils#SMOKECOLOR SmokeColor --- @field Utilities.Utils#FLARECOLOR FlareColor --- @field #POINT_VEC3.RoutePointAltType RoutePointAltType --- @field #POINT_VEC3.RoutePointType RoutePointType --- @field #POINT_VEC3.RoutePointAction RoutePointAction --- @extends Core.Point#COORDINATE - - ---- # POINT_VEC3 class, extends @{Point#COORDINATE} --- --- POINT_VEC3 defines a 3D point in the simulator and with its methods, you can use or manipulate the point in 3D space. --- --- **Important Note:** Most of the functions in this section were taken from MIST, and reworked to OO concepts. --- In order to keep the credibility of the the author, --- I want to emphasize that the formulas embedded in the MIST framework were created by Grimes or previous authors, --- who you can find on the Eagle Dynamics Forums. --- --- --- ## POINT_VEC3 constructor --- --- A new POINT_VEC3 object can be created with: --- --- * @{#POINT_VEC3.New}(): a 3D point. --- * @{#POINT_VEC3.NewFromVec3}(): a 3D point created from a @{DCSTypes#Vec3}. --- --- --- ## Manupulate the X, Y, Z coordinates of the POINT_VEC3 --- --- A POINT_VEC3 class works in 3D space. It contains internally an X, Y, Z coordinate. --- Methods exist to manupulate these coordinates. --- --- The current X, Y, Z axis can be retrieved with the methods @{#POINT_VEC3.GetX}(), @{#POINT_VEC3.GetY}(), @{#POINT_VEC3.GetZ}() respectively. --- The methods @{#POINT_VEC3.SetX}(), @{#POINT_VEC3.SetY}(), @{#POINT_VEC3.SetZ}() change the respective axis with a new value. --- The current axis values can be changed by using the methods @{#POINT_VEC3.AddX}(), @{#POINT_VEC3.AddY}(), @{#POINT_VEC3.AddZ}() --- to add or substract a value from the current respective axis value. --- Note that the Set and Add methods return the current POINT_VEC3 object, so these manipulation methods can be chained... For example: --- --- local Vec3 = PointVec3:AddX( 100 ):AddZ( 150 ):GetVec3() --- --- --- ## Create waypoints for routes --- --- A POINT_VEC3 can prepare waypoints for Ground and Air groups to be embedded into a Route. --- --- * @{#POINT_VEC3.RoutePointAir}(): Build an air route point. --- * @{#POINT_VEC3.RoutePointGround}(): Build a ground route point. --- --- Route points can be used in the Route methods of the @{Group#GROUP} class. --- --- --- ## Smoke, flare, explode, illuminate --- --- At the point a smoke, flare, explosion and illumination bomb can be triggered. Use the following methods: --- --- ### Smoke --- --- * @{#POINT_VEC3.Smoke}(): To smoke the point in a certain color. --- * @{#POINT_VEC3.SmokeBlue}(): To smoke the point in blue. --- * @{#POINT_VEC3.SmokeRed}(): To smoke the point in red. --- * @{#POINT_VEC3.SmokeOrange}(): To smoke the point in orange. --- * @{#POINT_VEC3.SmokeWhite}(): To smoke the point in white. --- * @{#POINT_VEC3.SmokeGreen}(): To smoke the point in green. --- --- ### Flare --- --- * @{#POINT_VEC3.Flare}(): To flare the point in a certain color. --- * @{#POINT_VEC3.FlareRed}(): To flare the point in red. --- * @{#POINT_VEC3.FlareYellow}(): To flare the point in yellow. --- * @{#POINT_VEC3.FlareWhite}(): To flare the point in white. --- * @{#POINT_VEC3.FlareGreen}(): To flare the point in green. --- --- ### Explode --- --- * @{#POINT_VEC3.Explosion}(): To explode the point with a certain intensity. --- --- ### Illuminate --- --- * @{#POINT_VEC3.IlluminationBomb}(): To illuminate the point. --- --- --- ## 3D calculation methods --- --- Various calculation methods exist to use or manipulate 3D space. Find below a short description of each method: --- --- ### Distance --- --- * @{#POINT_VEC3.Get3DDistance}(): Obtain the distance from the current 3D point to the provided 3D point in 3D space. --- * @{#POINT_VEC3.Get2DDistance}(): Obtain the distance from the current 3D point to the provided 3D point in 2D space. --- --- ### Angle --- --- * @{#POINT_VEC3.GetAngleDegrees}(): Obtain the angle in degrees from the current 3D point with the provided 3D direction vector. --- * @{#POINT_VEC3.GetAngleRadians}(): Obtain the angle in radians from the current 3D point with the provided 3D direction vector. --- * @{#POINT_VEC3.GetDirectionVec3}(): Obtain the 3D direction vector from the current 3D point to the provided 3D point. --- --- ### Translation --- --- * @{#POINT_VEC3.Translate}(): Translate the current 3D point towards an other 3D point using the given Distance and Angle. --- --- ### Get the North correction of the current location --- --- * @{#POINT_VEC3.GetNorthCorrection}(): Obtains the north correction at the current 3D point. --- --- --- ## Point Randomization --- --- Various methods exist to calculate random locations around a given 3D point. --- --- * @{#POINT_VEC3.GetRandomPointVec2InRadius}(): Provides a random 2D point around the current 3D point, in the given inner to outer band. --- * @{#POINT_VEC3.GetRandomPointVec3InRadius}(): Provides a random 3D point around the current 3D point, in the given inner to outer band. --- * @{#POINT_VEC3.GetRandomVec2InRadius}(): Provides a random 2D vector around the current 3D point, in the given inner to outer band. --- * @{#POINT_VEC3.GetRandomVec3InRadius}(): Provides a random 3D vector around the current 3D point, in the given inner to outer band. --- --- --- ## Metric system --- --- * @{#POINT_VEC3.IsMetric}(): Returns if the 3D point is Metric or Nautical Miles. --- * @{#POINT_VEC3.SetMetric}(): Sets the 3D point to Metric or Nautical Miles. --- --- --- ## Coorinate text generation --- --- * @{#POINT_VEC3.ToStringBR}(): Generates a Bearing & Range text in the format of DDD for DI where DDD is degrees and DI is distance. --- * @{#POINT_VEC3.ToStringLL}(): Generates a Latutude & Longutude text. --- --- @field #POINT_VEC3 -POINT_VEC3 = { - ClassName = "POINT_VEC3", - Metric = true, - RoutePointAltType = { - BARO = "BARO", - }, - RoutePointType = { - TakeOffParking = "TakeOffParking", - TurningPoint = "Turning Point", - }, - RoutePointAction = { - FromParkingArea = "From Parking Area", - TurningPoint = "Turning Point", - }, -} - ---- @type POINT_VEC2 --- @field Dcs.DCSTypes#Distance x The x coordinate in meters. --- @field Dcs.DCSTypes#Distance y the y coordinate in meters. --- @extends Core.Point#COORDINATE - - - ---- # POINT_VEC2 class, extends @{Point#COORDINATE} --- --- The @{Point#POINT_VEC2} class defines a 2D point in the simulator. The height coordinate (if needed) will be the land height + an optional added height specified. --- --- ## POINT_VEC2 constructor --- --- A new POINT_VEC2 instance can be created with: --- --- * @{Point#POINT_VEC2.New}(): a 2D point, taking an additional height parameter. --- * @{Point#POINT_VEC2.NewFromVec2}(): a 2D point created from a @{DCSTypes#Vec2}. --- --- ## Manupulate the X, Altitude, Y coordinates of the 2D point --- --- A POINT_VEC2 class works in 2D space, with an altitude setting. It contains internally an X, Altitude, Y coordinate. --- Methods exist to manupulate these coordinates. --- --- The current X, Altitude, Y axis can be retrieved with the methods @{#POINT_VEC2.GetX}(), @{#POINT_VEC2.GetAlt}(), @{#POINT_VEC2.GetY}() respectively. --- The methods @{#POINT_VEC2.SetX}(), @{#POINT_VEC2.SetAlt}(), @{#POINT_VEC2.SetY}() change the respective axis with a new value. --- The current Lat(itude), Alt(itude), Lon(gitude) values can also be retrieved with the methods @{#POINT_VEC2.GetLat}(), @{#POINT_VEC2.GetAlt}(), @{#POINT_VEC2.GetLon}() respectively. --- The current axis values can be changed by using the methods @{#POINT_VEC2.AddX}(), @{#POINT_VEC2.AddAlt}(), @{#POINT_VEC2.AddY}() --- to add or substract a value from the current respective axis value. --- Note that the Set and Add methods return the current POINT_VEC2 object, so these manipulation methods can be chained... For example: --- --- local Vec2 = PointVec2:AddX( 100 ):AddY( 2000 ):GetVec2() --- --- @field #POINT_VEC2 -POINT_VEC2 = { - ClassName = "POINT_VEC2", -} do -- COORDINATE + --- @type COORDINATE + -- @extends Core.Base#BASE + + --- # COORDINATE class, extends @{Base#BASE} + -- + -- COORDINATE defines a 3D point in the simulator and with its methods, you can use or manipulate the point in 3D space. + -- + -- ## COORDINATE constructor + -- + -- A new COORDINATE object can be created with: + -- + -- * @{#COORDINATE.New}(): a 3D point. + -- * @{#COORDINATE.NewFromVec2}(): a 2D point created from a @{DCSTypes#Vec2}. + -- * @{#COORDINATE.NewFromVec3}(): a 3D point created from a @{DCSTypes#Vec3}. + -- + -- ## Create waypoints for routes + -- + -- A COORDINATE can prepare waypoints for Ground and Air groups to be embedded into a Route. + -- + -- * @{#COORDINATE.RoutePointAir}(): Build an air route point. + -- * @{#COORDINATE.RoutePointGround}(): Build a ground route point. + -- + -- Route points can be used in the Route methods of the @{Group#GROUP} class. + -- + -- + -- ## Smoke, flare, explode, illuminate + -- + -- At the point a smoke, flare, explosion and illumination bomb can be triggered. Use the following methods: + -- + -- ### Smoke + -- + -- * @{#COORDINATE.Smoke}(): To smoke the point in a certain color. + -- * @{#COORDINATE.SmokeBlue}(): To smoke the point in blue. + -- * @{#COORDINATE.SmokeRed}(): To smoke the point in red. + -- * @{#COORDINATE.SmokeOrange}(): To smoke the point in orange. + -- * @{#COORDINATE.SmokeWhite}(): To smoke the point in white. + -- * @{#COORDINATE.SmokeGreen}(): To smoke the point in green. + -- + -- ### Flare + -- + -- * @{#COORDINATE.Flare}(): To flare the point in a certain color. + -- * @{#COORDINATE.FlareRed}(): To flare the point in red. + -- * @{#COORDINATE.FlareYellow}(): To flare the point in yellow. + -- * @{#COORDINATE.FlareWhite}(): To flare the point in white. + -- * @{#COORDINATE.FlareGreen}(): To flare the point in green. + -- + -- ### Explode + -- + -- * @{#COORDINATE.Explosion}(): To explode the point with a certain intensity. + -- + -- ### Illuminate + -- + -- * @{#COORDINATE.IlluminationBomb}(): To illuminate the point. + -- + -- + -- ## 3D calculation methods + -- + -- Various calculation methods exist to use or manipulate 3D space. Find below a short description of each method: + -- + -- ### Distance + -- + -- * @{#COORDINATE.Get3DDistance}(): Obtain the distance from the current 3D point to the provided 3D point in 3D space. + -- * @{#COORDINATE.Get2DDistance}(): Obtain the distance from the current 3D point to the provided 3D point in 2D space. + -- + -- ### Angle + -- + -- * @{#COORDINATE.GetAngleDegrees}(): Obtain the angle in degrees from the current 3D point with the provided 3D direction vector. + -- * @{#COORDINATE.GetAngleRadians}(): Obtain the angle in radians from the current 3D point with the provided 3D direction vector. + -- * @{#COORDINATE.GetDirectionVec3}(): Obtain the 3D direction vector from the current 3D point to the provided 3D point. + -- + -- ### Translation + -- + -- * @{#COORDINATE.Translate}(): Translate the current 3D point towards an other 3D point using the given Distance and Angle. + -- + -- ### Get the North correction of the current location + -- + -- * @{#COORDINATE.GetNorthCorrection}(): Obtains the north correction at the current 3D point. + -- + -- + -- ## Point Randomization + -- + -- Various methods exist to calculate random locations around a given 3D point. + -- + -- * @{#COORDINATE.GetRandomVec2InRadius}(): Provides a random 2D vector around the current 3D point, in the given inner to outer band. + -- * @{#COORDINATE.GetRandomVec3InRadius}(): Provides a random 3D vector around the current 3D point, in the given inner to outer band. + -- + -- + -- ## Metric system + -- + -- * @{#COORDINATE.IsMetric}(): Returns if the 3D point is Metric or Nautical Miles. + -- * @{#COORDINATE.SetMetric}(): Sets the 3D point to Metric or Nautical Miles. + -- + -- + -- ## Coorinate text generation + -- + -- * @{#COORDINATE.ToStringBR}(): Generates a Bearing & Range text in the format of DDD for DI where DDD is degrees and DI is distance. + -- * @{#COORDINATE.ToStringLL}(): Generates a Latutude & Longutude text. + -- + -- @field #COORDINATE + COORDINATE = { + ClassName = "COORDINATE", + } + --- COORDINATE constructor. -- @param #COORDINATE self -- @param Dcs.DCSTypes#Distance x The x coordinate of the Vec3 point, pointing to the North. @@ -342,7 +229,83 @@ do -- COORDINATE function COORDINATE:GetVec2() return { x = self.x, y = self.z } end - + + --TODO: check this to replace + --- Calculate the distance from a reference @{DCSTypes#Vec2}. + -- @param #COORDINATE self + -- @param Dcs.DCSTypes#Vec2 Vec2Reference The reference @{DCSTypes#Vec2}. + -- @return Dcs.DCSTypes#Distance The distance from the reference @{DCSTypes#Vec2} in meters. + function COORDINATE:DistanceFromVec2( Vec2Reference ) + self:F2( Vec2Reference ) + + local Distance = ( ( Vec2Reference.x - self.x ) ^ 2 + ( Vec2Reference.y - self.z ) ^2 ) ^0.5 + + self:T2( Distance ) + return Distance + end + + + --- Add a Distance in meters from the COORDINATE orthonormal plane, with the given angle, and calculate the new COORDINATE. + -- @param #COORDINATE self + -- @param Dcs.DCSTypes#Distance Distance The Distance to be added in meters. + -- @param Dcs.DCSTypes#Angle Angle The Angle in degrees. + -- @return #COORDINATE The new calculated COORDINATE. + function COORDINATE:Translate( Distance, Angle ) + local SX = self.x + local SY = self.z + local Radians = Angle / 180 * math.pi + local TX = Distance * math.cos( Radians ) + SX + local TY = Distance * math.sin( Radians ) + SY + + return COORDINATE:NewFromVec2( { x = TX, y = TY } ) + end + + --- Return a random Vec2 within an Outer Radius and optionally NOT within an Inner Radius of the COORDINATE. + -- @param #COORDINATE self + -- @param Dcs.DCSTypes#Distance OuterRadius + -- @param Dcs.DCSTypes#Distance InnerRadius + -- @return Dcs.DCSTypes#Vec2 Vec2 + function COORDINATE:GetRandomVec2InRadius( OuterRadius, InnerRadius ) + self:F2( { OuterRadius, InnerRadius } ) + + local Theta = 2 * math.pi * math.random() + local Radials = math.random() + math.random() + if Radials > 1 then + Radials = 2 - Radials + end + + local RadialMultiplier + if InnerRadius and InnerRadius <= OuterRadius then + RadialMultiplier = ( OuterRadius - InnerRadius ) * Radials + InnerRadius + else + RadialMultiplier = OuterRadius * Radials + end + + local RandomVec2 + if OuterRadius > 0 then + RandomVec2 = { x = math.cos( Theta ) * RadialMultiplier + self.x, y = math.sin( Theta ) * RadialMultiplier + self.z } + else + RandomVec2 = { x = self.x, y = self.z } + end + + return RandomVec2 + end + + + --- Return a random Vec3 within an Outer Radius and optionally NOT within an Inner Radius of the COORDINATE. + -- @param #COORDINATE self + -- @param Dcs.DCSTypes#Distance OuterRadius + -- @param Dcs.DCSTypes#Distance InnerRadius + -- @return Dcs.DCSTypes#Vec3 Vec3 + function COORDINATE:GetRandomVec3InRadius( OuterRadius, InnerRadius ) + + local RandomVec2 = self:GetRandomVec2InRadius( OuterRadius, InnerRadius ) + local y = self.y + math.random( InnerRadius, OuterRadius ) + local RandomVec3 = { x = RandomVec2.x, y = y, z = RandomVec2.y } + + return RandomVec3 + end + function COORDINATE:SetHeading( Heading ) self.Heading = Heading @@ -706,7 +669,7 @@ do -- COORDINATE self:Flare( FLARECOLOR.Red, Azimuth ) end - --- Returns if a Coordinate has Line of Sight (LOS) with the ToPointVec3. + --- Returns if a Coordinate has Line of Sight (LOS) with the ToCoordinate. -- @param #COORDINATE self -- @param #COORDINATE ToCoordinate -- @return #boolean true If the ToCoordinate has LOS with the Coordinate, otherwise false. @@ -890,6 +853,80 @@ end do -- POINT_VEC3 + --- The POINT_VEC3 class + -- @type POINT_VEC3 + -- @field #number x The x coordinate in 3D space. + -- @field #number y The y coordinate in 3D space. + -- @field #number z The z coordiante in 3D space. + -- @field Utilities.Utils#SMOKECOLOR SmokeColor + -- @field Utilities.Utils#FLARECOLOR FlareColor + -- @field #POINT_VEC3.RoutePointAltType RoutePointAltType + -- @field #POINT_VEC3.RoutePointType RoutePointType + -- @field #POINT_VEC3.RoutePointAction RoutePointAction + -- @extends Core.Point#COORDINATE + + + --- # POINT_VEC3 class, extends @{Point#COORDINATE} + -- + -- POINT_VEC3 defines a 3D point in the simulator and with its methods, you can use or manipulate the point in 3D space. + -- + -- **Important Note:** Most of the functions in this section were taken from MIST, and reworked to OO concepts. + -- In order to keep the credibility of the the author, + -- I want to emphasize that the formulas embedded in the MIST framework were created by Grimes or previous authors, + -- who you can find on the Eagle Dynamics Forums. + -- + -- + -- ## POINT_VEC3 constructor + -- + -- A new POINT_VEC3 object can be created with: + -- + -- * @{#POINT_VEC3.New}(): a 3D point. + -- * @{#POINT_VEC3.NewFromVec3}(): a 3D point created from a @{DCSTypes#Vec3}. + -- + -- + -- ## Manupulate the X, Y, Z coordinates of the POINT_VEC3 + -- + -- A POINT_VEC3 class works in 3D space. It contains internally an X, Y, Z coordinate. + -- Methods exist to manupulate these coordinates. + -- + -- The current X, Y, Z axis can be retrieved with the methods @{#POINT_VEC3.GetX}(), @{#POINT_VEC3.GetY}(), @{#POINT_VEC3.GetZ}() respectively. + -- The methods @{#POINT_VEC3.SetX}(), @{#POINT_VEC3.SetY}(), @{#POINT_VEC3.SetZ}() change the respective axis with a new value. + -- The current axis values can be changed by using the methods @{#POINT_VEC3.AddX}(), @{#POINT_VEC3.AddY}(), @{#POINT_VEC3.AddZ}() + -- to add or substract a value from the current respective axis value. + -- Note that the Set and Add methods return the current POINT_VEC3 object, so these manipulation methods can be chained... For example: + -- + -- local Vec3 = PointVec3:AddX( 100 ):AddZ( 150 ):GetVec3() + -- + -- + -- ## 3D calculation methods + -- + -- Various calculation methods exist to use or manipulate 3D space. Find below a short description of each method: + -- + -- + -- ## Point Randomization + -- + -- Various methods exist to calculate random locations around a given 3D point. + -- + -- * @{#POINT_VEC3.GetRandomPointVec3InRadius}(): Provides a random 3D point around the current 3D point, in the given inner to outer band. + -- + -- + -- @field #POINT_VEC3 + POINT_VEC3 = { + ClassName = "POINT_VEC3", + Metric = true, + RoutePointAltType = { + BARO = "BARO", + }, + RoutePointType = { + TakeOffParking = "TakeOffParking", + TurningPoint = "Turning Point", + }, + RoutePointAction = { + FromParkingArea = "From Parking Area", + TurningPoint = "Turning Point", + }, + } + --- RoutePoint AltTypes -- @type POINT_VEC3.RoutePointAltType -- @field BARO "BARO" @@ -916,7 +953,7 @@ do -- POINT_VEC3 local self = BASE:Inherit( self, COORDINATE:New( x, y, z ) ) -- Core.Point#POINT_VEC3 self:F2( self ) - + return self end @@ -1023,20 +1060,6 @@ do -- POINT_VEC3 return self end - --- Return a random Vec3 within an Outer Radius and optionally NOT within an Inner Radius of the POINT_VEC3. - -- @param #POINT_VEC3 self - -- @param Dcs.DCSTypes#Distance OuterRadius - -- @param Dcs.DCSTypes#Distance InnerRadius - -- @return Dcs.DCSTypes#Vec3 Vec3 - function POINT_VEC3:GetRandomVec3InRadius( OuterRadius, InnerRadius ) - - local RandomVec2 = self:GetRandomVec2InRadius( OuterRadius, InnerRadius ) - local y = self:GetY() + math.random( InnerRadius, OuterRadius ) - local RandomVec3 = { x = RandomVec2.x, y = y, z = RandomVec2.y } - - return RandomVec3 - end - --- Return a random POINT_VEC3 within an Outer Radius and optionally NOT within an Inner Radius of the POINT_VEC3. -- @param #POINT_VEC3 self -- @param Dcs.DCSTypes#Distance OuterRadius @@ -1051,6 +1074,41 @@ end do -- POINT_VEC2 + --- @type POINT_VEC2 + -- @field Dcs.DCSTypes#Distance x The x coordinate in meters. + -- @field Dcs.DCSTypes#Distance y the y coordinate in meters. + -- @extends Core.Point#COORDINATE + + --- # POINT_VEC2 class, extends @{Point#COORDINATE} + -- + -- The @{Point#POINT_VEC2} class defines a 2D point in the simulator. The height coordinate (if needed) will be the land height + an optional added height specified. + -- + -- ## POINT_VEC2 constructor + -- + -- A new POINT_VEC2 instance can be created with: + -- + -- * @{Point#POINT_VEC2.New}(): a 2D point, taking an additional height parameter. + -- * @{Point#POINT_VEC2.NewFromVec2}(): a 2D point created from a @{DCSTypes#Vec2}. + -- + -- ## Manupulate the X, Altitude, Y coordinates of the 2D point + -- + -- A POINT_VEC2 class works in 2D space, with an altitude setting. It contains internally an X, Altitude, Y coordinate. + -- Methods exist to manupulate these coordinates. + -- + -- The current X, Altitude, Y axis can be retrieved with the methods @{#POINT_VEC2.GetX}(), @{#POINT_VEC2.GetAlt}(), @{#POINT_VEC2.GetY}() respectively. + -- The methods @{#POINT_VEC2.SetX}(), @{#POINT_VEC2.SetAlt}(), @{#POINT_VEC2.SetY}() change the respective axis with a new value. + -- The current Lat(itude), Alt(itude), Lon(gitude) values can also be retrieved with the methods @{#POINT_VEC2.GetLat}(), @{#POINT_VEC2.GetAlt}(), @{#POINT_VEC2.GetLon}() respectively. + -- The current axis values can be changed by using the methods @{#POINT_VEC2.AddX}(), @{#POINT_VEC2.AddAlt}(), @{#POINT_VEC2.AddY}() + -- to add or substract a value from the current respective axis value. + -- Note that the Set and Add methods return the current POINT_VEC2 object, so these manipulation methods can be chained... For example: + -- + -- local Vec2 = PointVec2:AddX( 100 ):AddY( 2000 ):GetVec2() + -- + -- @field #POINT_VEC2 + POINT_VEC2 = { + ClassName = "POINT_VEC2", + } + --- POINT_VEC2 constructor. @@ -1210,36 +1268,6 @@ do -- POINT_VEC2 return self end - --- Return a random Vec2 within an Outer Radius and optionally NOT within an Inner Radius of the POINT_VEC2. - -- @param #POINT_VEC2 self - -- @param Dcs.DCSTypes#Distance OuterRadius - -- @param Dcs.DCSTypes#Distance InnerRadius - -- @return Dcs.DCSTypes#Vec2 Vec2 - function POINT_VEC2:GetRandomVec2InRadius( OuterRadius, InnerRadius ) - self:F2( { OuterRadius, InnerRadius } ) - - local Theta = 2 * math.pi * math.random() - local Radials = math.random() + math.random() - if Radials > 1 then - Radials = 2 - Radials - end - - local RadialMultiplier - if InnerRadius and InnerRadius <= OuterRadius then - RadialMultiplier = ( OuterRadius - InnerRadius ) * Radials + InnerRadius - else - RadialMultiplier = OuterRadius * Radials - end - - local RandomVec2 - if OuterRadius > 0 then - RandomVec2 = { x = math.cos( Theta ) * RadialMultiplier + self:GetX(), y = math.sin( Theta ) * RadialMultiplier + self:GetZ() } - else - RandomVec2 = { x = self:GetX(), y = self:GetZ() } - end - - return RandomVec2 - end --- Return a random POINT_VEC2 within an Outer Radius and optionally NOT within an Inner Radius of the POINT_VEC2. -- @param #POINT_VEC2 self @@ -1252,8 +1280,7 @@ do -- POINT_VEC2 return POINT_VEC2:NewFromVec2( self:GetRandomVec2InRadius( OuterRadius, InnerRadius ) ) end - --- TODO: Check this to replace + -- TODO: Check this to replace --- Calculate the distance from a reference @{#POINT_VEC2}. -- @param #POINT_VEC2 self -- @param #POINT_VEC2 PointVec2Reference The reference @{#POINT_VEC2}. @@ -1261,43 +1288,12 @@ do -- POINT_VEC2 function POINT_VEC2:DistanceFromPointVec2( PointVec2Reference ) self:F2( PointVec2Reference ) - local Distance = ( ( PointVec2Reference:GetX() - self:GetX() ) ^ 2 + ( PointVec2Reference:GetY() - self:GetY() ) ^2 ) ^0.5 + local Distance = ( ( PointVec2Reference.x - self.x ) ^ 2 + ( PointVec2Reference.z - self.z ) ^2 ) ^ 0.5 self:T2( Distance ) return Distance end ---TODO: check this to replace - - --- Calculate the distance from a reference @{DCSTypes#Vec2}. - -- @param #POINT_VEC2 self - -- @param Dcs.DCSTypes#Vec2 Vec2Reference The reference @{DCSTypes#Vec2}. - -- @return Dcs.DCSTypes#Distance The distance from the reference @{DCSTypes#Vec2} in meters. - function POINT_VEC2:DistanceFromVec2( Vec2Reference ) - self:F2( Vec2Reference ) - - local Distance = ( ( Vec2Reference.x - self:GetX() ) ^ 2 + ( Vec2Reference.y - self:GetY() ) ^2 ) ^0.5 - - self:T2( Distance ) - return Distance - end - - - --- Add a Distance in meters from the POINT_VEC2 orthonormal plane, with the given angle, and calculate the new POINT_VEC2. - -- @param #POINT_VEC2 self - -- @param Dcs.DCSTypes#Distance Distance The Distance to be added in meters. - -- @param Dcs.DCSTypes#Angle Angle The Angle in degrees. - -- @return #POINT_VEC2 The new calculated POINT_VEC2. - function POINT_VEC2:Translate( Distance, Angle ) - local SX = self:GetX() - local SY = self:GetY() - local Radians = Angle / 180 * math.pi - local TX = Distance * math.cos( Radians ) + SX - local TY = Distance * math.sin( Radians ) + SY - - return POINT_VEC2:New( TX, TY ) - end - end diff --git a/docs/Documentation/Detection.html b/docs/Documentation/Detection.html index a1c42a3b0..5cbd9bb85 100644 --- a/docs/Documentation/Detection.html +++ b/docs/Documentation/Detection.html @@ -2526,7 +2526,7 @@ The index of the DetectedItem.

- + #number DETECTION_BASE.DetectionInterval diff --git a/docs/Documentation/Fsm.html b/docs/Documentation/Fsm.html index c5184cb8d..1b1039138 100644 --- a/docs/Documentation/Fsm.html +++ b/docs/Documentation/Fsm.html @@ -1627,7 +1627,7 @@ A string defining the start state.

- + #string FSM._StartState @@ -1926,7 +1926,6 @@ A string defining the start state.

- FSM.current diff --git a/docs/Documentation/Point.html b/docs/Documentation/Point.html index 990058fa7..dee30da78 100644 --- a/docs/Documentation/Point.html +++ b/docs/Documentation/Point.html @@ -167,7 +167,7 @@

COORDINATE class, extends Base#BASE

-

The COORDINATE class defines a 2D coordinate in the simulator.

+

COORDINATE defines a 3D point in the simulator and with its methods, you can use or manipulate the point in 3D space.

@@ -190,6 +190,12 @@

Type COORDINATE

+ + + + + + + + + + + + @@ -312,7 +330,7 @@ @@ -463,7 +481,7 @@ @@ -510,12 +528,6 @@ - - - - @@ -540,12 +552,6 @@ - - - - @@ -606,12 +612,6 @@ - - - - @@ -664,12 +664,6 @@ - - - - @@ -825,35 +819,126 @@

COORDINATE class, extends Base#BASE

-

The COORDINATE class defines a 2D coordinate in the simulator.

+

COORDINATE defines a 3D point in the simulator and with its methods, you can use or manipulate the point in 3D space.

-

The height coordinate (if needed) will be the land height + an optional added height specified. -A COORDINATE can be expressed in LL or in MGRS.

COORDINATE constructor

-

A new COORDINATE instance can be created with:

+

A new COORDINATE object can be created with:

-

Manupulate the X, Altitude, Y coordinates of the 2D point

+

Create waypoints for routes

-

A COORDINATE class works in 2D space, with an altitude setting. It contains internally an X, Altitude, Y coordinate. -Methods exist to manupulate these coordinates.

+

A COORDINATE can prepare waypoints for Ground and Air groups to be embedded into a Route.

-

The current X, Altitude, Y axis can be retrieved with the methods COORDINATE.GetX(), COORDINATE.GetAlt(), COORDINATE.GetY() respectively. -The methods COORDINATE.SetX(), COORDINATE.SetAlt(), COORDINATE.SetY() change the respective axis with a new value. -The current Lat(itude), Alt(itude), Lon(gitude) values can also be retrieved with the methods COORDINATE.GetLat(), COORDINATE.GetAlt(), COORDINATE.GetLon() respectively. -The current axis values can be changed by using the methods COORDINATE.AddX(), COORDINATE.AddAlt(), COORDINATE.AddY() -to add or substract a value from the current respective axis value. -Note that the Set and Add methods return the current COORDINATE object, so these manipulation methods can be chained... For example:

+ -
 local Vec2 = PointVec2:AddX( 100 ):AddY( 2000 ):GetVec2()
-
+

Route points can be used in the Route methods of the Group#GROUP class.

+ + +

Smoke, flare, explode, illuminate

+ +

At the point a smoke, flare, explosion and illumination bomb can be triggered. Use the following methods:

+ +

Smoke

+ + + +

Flare

+ + + +

Explode

+ + + +

Illuminate

+ + + + +

3D calculation methods

+ +

Various calculation methods exist to use or manipulate 3D space. Find below a short description of each method:

+ +

Distance

+ + + +

Angle

+ + + +

Translation

+ +
    +
  • COORDINATE.Translate(): Translate the current 3D point towards an other 3D point using the given Distance and Angle.
  • +
+ +

Get the North correction of the current location

+ + + + +

Point Randomization

+ +

Various methods exist to calculate random locations around a given 3D point.

+ + + + +

Metric system

+ + + + +

Coorinate text generation

+ + @@ -949,115 +1034,20 @@ Note that the Set and Add methods return the current POINT_VEC3 object, so these -

Create waypoints for routes

- -

A POINT_VEC3 can prepare waypoints for Ground and Air groups to be embedded into a Route.

- - - -

Route points can be used in the Route methods of the Group#GROUP class.

- - -

Smoke, flare, explode, illuminate

- -

At the point a smoke, flare, explosion and illumination bomb can be triggered. Use the following methods:

- -

Smoke

- - - -

Flare

- - - -

Explode

- - - -

Illuminate

- - - -

3D calculation methods

Various calculation methods exist to use or manipulate 3D space. Find below a short description of each method:

-

Distance

- - - -

Angle

- - - -

Translation

- -
    -
  • POINT_VEC3.Translate(): Translate the current 3D point towards an other 3D point using the given Distance and Angle.
  • -
- -

Get the North correction of the current location

- - -

Point Randomization

Various methods exist to calculate random locations around a given 3D point.

-

Metric system

- - - - -

Coorinate text generation

- - - @@ -1068,6 +1058,34 @@ Note that the Set and Add methods return the current POINT_VEC3 object, so these
+ +COORDINATE:DistanceFromVec2(Vec2Reference) + +
+
+ + + + +

TODO: check this to replace +- Calculate the distance from a reference DCSTypes#Vec2. + @param #COORDINATE self + @param Dcs.DCSTypes#Vec2 Vec2Reference The reference DCSTypes#Vec2. + @return Dcs.DCSTypes#Distance The distance from the reference DCSTypes#Vec2 in meters.

+ +

Parameter

+
    +
  • + +

    Vec2Reference :

    + +
  • +
+
+
+
+
+ COORDINATE:Explosion(ExplosionIntensity) @@ -1548,6 +1566,68 @@ CorrectionRadians The correction in radians.

+ +COORDINATE:GetRandomVec2InRadius(OuterRadius, InnerRadius) + +
+
+ +

Return a random Vec2 within an Outer Radius and optionally NOT within an Inner Radius of the COORDINATE.

+ +

Parameters

+ +

Return value

+ +

Dcs.DCSTypes#Vec2: +Vec2

+ +
+
+
+
+ + +COORDINATE:GetRandomVec3InRadius(OuterRadius, InnerRadius) + +
+
+ +

Return a random Vec3 within an Outer Radius and optionally NOT within an Inner Radius of the COORDINATE.

+ +

Parameters

+ +

Return value

+ +

Dcs.DCSTypes#Vec3: +Vec3

+ +
+
+
+
+ COORDINATE:GetVec2() @@ -1603,7 +1683,7 @@ The Vec3 format coordinate.

-

Returns if a Coordinate has Line of Sight (LOS) with the ToPointVec3.

+

Returns if a Coordinate has Line of Sight (LOS) with the ToCoordinate.

Parameter

    @@ -2229,7 +2309,7 @@ The MGRS Text

-

Add a Distance in meters from the COORDINATE horizontal plane, with the given angle, and calculate the new COORDINATE.

+

Add a Distance in meters from the COORDINATE orthonormal plane, with the given angle, and calculate the new COORDINATE.

Parameters

-
-
-
- - -POINT_VEC2:GetRandomVec2InRadius(OuterRadius, InnerRadius) - -
-
- -

Return a random Vec2 within an Outer Radius and optionally NOT within an Inner Radius of the POINT_VEC2.

- -

Parameters

- -

Return value

- -

Dcs.DCSTypes#Vec2: -Vec2

-
@@ -2828,39 +2850,6 @@ The y coordinate.

#POINT_VEC2:

- -
-
-
- - -POINT_VEC2:Translate(Distance, Angle) - -
-
- -

Add a Distance in meters from the POINTVEC2 orthonormal plane, with the given angle, and calculate the new POINTVEC2.

- -

Parameters

- -

Return value

- -

#POINT_VEC2: -The new calculated POINT_VEC2.

-
@@ -2894,7 +2883,6 @@ The new calculated POINT_VEC2.

- POINT_VEC2.z @@ -3035,37 +3023,6 @@ The z coordinate value to add to the current z coodinate.

#POINT_VEC3:

- -
-
-
- - -POINT_VEC3:GetRandomVec3InRadius(OuterRadius, InnerRadius) - -
-
- -

Return a random Vec3 within an Outer Radius and optionally NOT within an Inner Radius of the POINT_VEC3.

- -

Parameters

- -

Return value

- -

Dcs.DCSTypes#Vec3: -Vec3

-
diff --git a/docs/Documentation/Settings.html b/docs/Documentation/Settings.html index 354a931f0..fdfdf1448 100644 --- a/docs/Documentation/Settings.html +++ b/docs/Documentation/Settings.html @@ -1071,7 +1071,7 @@ true if metric.

- + #boolean SETTINGS.Metric diff --git a/docs/Documentation/Spawn.html b/docs/Documentation/Spawn.html index a69c39851..c96559421 100644 --- a/docs/Documentation/Spawn.html +++ b/docs/Documentation/Spawn.html @@ -2532,6 +2532,9 @@ when nothing was spawned.

+ +

Overwrite unit names by default with group name.

+
@@ -2950,7 +2953,7 @@ Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' ):Schedule( 600, 0.5 ) -

When the first Spawn executes, all the Groups need to be made visible before start.

+

Flag that indicates if all the Groups of the SpawnGroup need to be visible when Spawned.

diff --git a/docs/Documentation/Task_A2A_Dispatcher.html b/docs/Documentation/Task_A2A_Dispatcher.html index 5faeb923b..56997d179 100644 --- a/docs/Documentation/Task_A2A_Dispatcher.html +++ b/docs/Documentation/Task_A2A_Dispatcher.html @@ -185,7 +185,7 @@ Find a summary below describing for which situation a task type is created:

- + @@ -366,7 +366,7 @@ If there are no targets to be set.

-TASK_A2A_DISPATCHER:EvaluateRemoveTask(Mission, Task, Detection, DetectedItemID, DetectedItemChange, DetectedItem, DetectedItemChanged) +TASK_A2A_DISPATCHER:EvaluateRemoveTask(Mission, Task, Detection, DetectedItemID, DetectedItemChange, DetectedItem, DetectedItemIndex, DetectedItemChanged)
@@ -411,6 +411,11 @@ The detection created by the Detectio
  • +

    DetectedItemIndex :

    + +
  • +
  • +

    DetectedItemChanged :

  • diff --git a/docs/Documentation/Task_A2G_Dispatcher.html b/docs/Documentation/Task_A2G_Dispatcher.html index c7e1a142b..be44cb25b 100644 --- a/docs/Documentation/Task_A2G_Dispatcher.html +++ b/docs/Documentation/Task_A2G_Dispatcher.html @@ -187,7 +187,7 @@ Find a summary below describing for which situation a task type is created:

    - + @@ -347,7 +347,7 @@ Find a summary below describing for which situation a task type is created:

    -TASK_A2G_DISPATCHER:EvaluateRemoveTask(Mission, Task, DetectedItemID, DetectedItemChange, DetectedItemChanged) +TASK_A2G_DISPATCHER:EvaluateRemoveTask(Mission, Task, DetectedItemID, DetectedItemChange, TaskIndex, DetectedItemChanged)
    @@ -381,6 +381,11 @@ Find a summary below describing for which situation a task type is created:

  • +

    TaskIndex :

    + +
  • +
  • +

    DetectedItemChanged :

  • diff --git a/docs/Documentation/Task_Cargo.html b/docs/Documentation/Task_Cargo.html index adb4ba2fe..5740dc732 100644 --- a/docs/Documentation/Task_Cargo.html +++ b/docs/Documentation/Task_Cargo.html @@ -506,7 +506,7 @@ based on the tasking capabilities defined in Task#TA
    - Core.Cargo#CARGO + Core.Cargo#CARGO_GROUP FSM_PROCESS.Cargo @@ -520,6 +520,7 @@ based on the tasking capabilities defined in Task#TA
    + FSM_PROCESS.DeployZone
    COORDINATE:DistanceFromVec2(Vec2Reference) + +
    COORDINATE:Explosion(ExplosionIntensity)

    Creates an explosion at the point of a certain intensity.

    @@ -289,6 +295,18 @@
    COORDINATE:GetNorthCorrectionRadians()

    Get a correction in radians of the real magnetic north of the COORDINATE.

    +
    COORDINATE:GetRandomVec2InRadius(OuterRadius, InnerRadius) +

    Return a random Vec2 within an Outer Radius and optionally NOT within an Inner Radius of the COORDINATE.

    +
    COORDINATE:GetRandomVec3InRadius(OuterRadius, InnerRadius) +

    Return a random Vec3 within an Outer Radius and optionally NOT within an Inner Radius of the COORDINATE.

    COORDINATE:IsLOS(ToCoordinate) -

    Returns if a Coordinate has Line of Sight (LOS) with the ToPointVec3.

    +

    Returns if a Coordinate has Line of Sight (LOS) with the ToCoordinate.

    COORDINATE:Translate(Distance, Angle) -

    Add a Distance in meters from the COORDINATE horizontal plane, with the given angle, and calculate the new COORDINATE.

    +

    Add a Distance in meters from the COORDINATE orthonormal plane, with the given angle, and calculate the new COORDINATE.

    POINT_VEC2:DistanceFromPointVec2(PointVec2Reference) -
    POINT_VEC2:DistanceFromVec2(Vec2Reference) -

    Calculate the distance from a reference DCSTypes#Vec2.

    POINT_VEC2:GetRandomPointVec2InRadius(OuterRadius, InnerRadius)

    Return a random POINTVEC2 within an Outer Radius and optionally NOT within an Inner Radius of the POINTVEC2.

    -
    POINT_VEC2:GetRandomVec2InRadius(OuterRadius, InnerRadius) -

    Return a random Vec2 within an Outer Radius and optionally NOT within an Inner Radius of the POINT_VEC2.

    POINT_VEC2:SetY(y)

    Set the y coordinate of the POINT_VEC2.

    -
    POINT_VEC2:Translate(Distance, Angle) -

    Add a Distance in meters from the POINTVEC2 orthonormal plane, with the given angle, and calculate the new POINTVEC2.

    POINT_VEC3:GetRandomPointVec3InRadius(OuterRadius, InnerRadius)

    Return a random POINTVEC3 within an Outer Radius and optionally NOT within an Inner Radius of the POINTVEC3.

    -
    POINT_VEC3:GetRandomVec3InRadius(OuterRadius, InnerRadius) -

    Return a random Vec3 within an Outer Radius and optionally NOT within an Inner Radius of the POINT_VEC3.

    TASK_A2A_DISPATCHER:EvaluateRemoveTask(Mission, Task, Detection, DetectedItemID, DetectedItemChange, DetectedItem, DetectedItemChanged)TASK_A2A_DISPATCHER:EvaluateRemoveTask(Mission, Task, Detection, DetectedItemID, DetectedItemChange, DetectedItem, DetectedItemIndex, DetectedItemChanged)

    Evaluates the removal of the Task from the Mission.

    TASK_A2G_DISPATCHER:EvaluateRemoveTask(Mission, Task, DetectedItemID, DetectedItemChange, DetectedItemChanged)TASK_A2G_DISPATCHER:EvaluateRemoveTask(Mission, Task, DetectedItemID, DetectedItemChange, TaskIndex, DetectedItemChanged)

    Evaluates the removal of the Task from the Mission.