From 312007b51cc92ac07285ed30e943284711c9f17c Mon Sep 17 00:00:00 2001 From: FlightControl Date: Thu, 18 May 2017 20:53:15 +0200 Subject: [PATCH] Progress --- Moose Development/Maths/Aspect.ggb | Bin 0 -> 7404 bytes Moose Development/Moose/Core/Point.lua | 1699 +++++++++-------- .../Moose/Functional/Detection.lua | 15 +- Moose Development/Moose/Tasking/Task.lua | 4 +- .../Moose/Tasking/Task_A2A_Dispatcher.lua | 2 + .../Moose/Wrapper/Positionable.lua | 1 + 6 files changed, 879 insertions(+), 842 deletions(-) create mode 100644 Moose Development/Maths/Aspect.ggb diff --git a/Moose Development/Maths/Aspect.ggb b/Moose Development/Maths/Aspect.ggb new file mode 100644 index 0000000000000000000000000000000000000000..be76e89b2c6a543c44d57a72754983d105dc6d37 GIT binary patch literal 7404 zcmb7}1xy`ZyRRvf4HPKu4#nNwq4)-hY@|S8TW+}+*X-HXeH;#Sh z|0Vb4oOd$Gth~vSmC4MSXMRgb4(2T;6g)gURAhdgEYx3x{rlR)$i~FTz+PX^(bUPx zz*^tTlF8QEWCG--p#sA0mNBFqCdaaqfUZ=})F)C>O7acOQyRoZ{=%}^mludD(FcV1 z=M;+YV+ZT?S!+Sa5?Wue#0`KxKgLq*HDPy>n2lomoWhU0o5h4=DUun9f0hdB@( z;Ky_E(QZ@yBLt}d9eaA>a|%jEabt;8Abc7ZV|2Q8wN8tZ=7DDHuyd))=<-?~rjyN$ zujAL(*I-wHW5&Sz%7T^_Ap9DdMvflV#WZQSi{Aq3_hix+^dmizc1oAws~>C2-vwP2 z9_ZMSh&@%TKDgZ+ohU^42E*ST`>SDx4`)ezu~?{5n_8T`5Ed&%;%k0ycbXMCzJKMS zW^W^EvQe5zfLXP-QS~E^C8-enZoE%*SX9u~e~*A?&S#3<*jz0kN5RG^XskQHFxiWR zo}V9B!KYL)J54I=dg04LAF0G3T^(2^{d#h}$a-fj*xq($&B4XV3ClVlUS5`UyZKdR zD{BqJpiNTv9*&`@q1|ynI~#eWQT2#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 x^rQYYk^c+%Z%6-6$lrJCkGlN3wlV$<`6Dt)a 1 then - Radials = 2 - Radials + return self end - local RadialMultiplier - if InnerRadius and InnerRadius <= OuterRadius then - RadialMultiplier = ( OuterRadius - InnerRadius ) * Radials + InnerRadius - else - RadialMultiplier = OuterRadius * Radials + --- Create a new POINT_VEC3 object from Vec2 coordinates. + -- @param #POINT_VEC3 self + -- @param Dcs.DCSTypes#Vec2 Vec2 The Vec2 point. + -- @return Core.Point#POINT_VEC3 self + function POINT_VEC3:NewFromVec2( Vec2, LandHeightAdd ) + + local LandHeight = land.getHeight( Vec2 ) + + LandHeightAdd = LandHeightAdd or 0 + LandHeight = LandHeight + LandHeightAdd + + self = self:New( Vec2.x, LandHeight, Vec2.y ) + + self:F2( self ) + + return self 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 + --- Create a new POINT_VEC3 object from Vec3 coordinates. + -- @param #POINT_VEC3 self + -- @param Dcs.DCSTypes#Vec3 Vec3 The Vec3 point. + -- @return Core.Point#POINT_VEC3 self + function POINT_VEC3:NewFromVec3( Vec3 ) ---- Return a random POINT_VEC2 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 #POINT_VEC2 -function POINT_VEC3:GetRandomPointVec2InRadius( OuterRadius, InnerRadius ) - self:F2( { OuterRadius, InnerRadius } ) - - return POINT_VEC2:NewFromVec2( self:GetRandomVec2InRadius( OuterRadius, InnerRadius ) ) -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 --- @param Dcs.DCSTypes#Distance InnerRadius --- @return #POINT_VEC3 -function POINT_VEC3:GetRandomPointVec3InRadius( OuterRadius, InnerRadius ) - - return POINT_VEC3:NewFromVec3( self:GetRandomVec3InRadius( OuterRadius, InnerRadius ) ) -end - - ---- Return a direction vector Vec3 from POINT_VEC3 to the POINT_VEC3. --- @param #POINT_VEC3 self --- @param #POINT_VEC3 TargetPointVec3 The target POINT_VEC3. --- @return Dcs.DCSTypes#Vec3 DirectionVec3 The direction vector in Vec3 format. -function POINT_VEC3:GetDirectionVec3( TargetPointVec3 ) - return { x = TargetPointVec3:GetX() - self:GetX(), y = TargetPointVec3:GetY() - self:GetY(), z = TargetPointVec3:GetZ() - self:GetZ() } -end - ---- Get a correction in radians of the real magnetic north of the POINT_VEC3. --- @param #POINT_VEC3 self --- @return #number CorrectionRadians The correction in radians. -function POINT_VEC3:GetNorthCorrectionRadians() - local TargetVec3 = self:GetVec3() - local lat, lon = coord.LOtoLL(TargetVec3) - local north_posit = coord.LLtoLO(lat + 1, lon) - return math.atan2( north_posit.z - TargetVec3.z, north_posit.x - TargetVec3.x ) -end - - ---- Return an angle in radians from the POINT_VEC3 using a direction vector in Vec3 format. --- @param #POINT_VEC3 self --- @param Dcs.DCSTypes#Vec3 DirectionVec3 The direction vector in Vec3 format. --- @return #number DirectionRadians The angle in radians. -function POINT_VEC3:GetAngleRadians( DirectionVec3 ) - local DirectionRadians = math.atan2( DirectionVec3.z, DirectionVec3.x ) - --DirectionRadians = DirectionRadians + self:GetNorthCorrectionRadians() - if DirectionRadians < 0 then - DirectionRadians = DirectionRadians + 2 * math.pi -- put dir in range of 0 to 2*pi ( the full circle ) - end - return DirectionRadians -end - ---- Return an angle in degrees from the POINT_VEC3 using a direction vector in Vec3 format. --- @param #POINT_VEC3 self --- @param Dcs.DCSTypes#Vec3 DirectionVec3 The direction vector in Vec3 format. --- @return #number DirectionRadians The angle in degrees. -function POINT_VEC3:GetAngleDegrees( DirectionVec3 ) - local AngleRadians = self:GetAngleRadians(DirectionVec3) - local Angle = UTILS.ToDegree( AngleRadians ) - return Angle -end - - ---- Return the 2D distance in meters between the target POINT_VEC3 and the POINT_VEC3. --- @param #POINT_VEC3 self --- @param #POINT_VEC3 TargetPointVec3 The target POINT_VEC3. --- @return Dcs.DCSTypes#Distance Distance The distance in meters. -function POINT_VEC3:Get2DDistance( TargetPointVec3 ) - local TargetVec3 = TargetPointVec3:GetVec3() - local SourceVec3 = self:GetVec3() - return ( ( TargetVec3.x - SourceVec3.x ) ^ 2 + ( TargetVec3.z - SourceVec3.z ) ^ 2 ) ^ 0.5 -end - ---- Return the 3D distance in meters between the target POINT_VEC3 and the POINT_VEC3. --- @param #POINT_VEC3 self --- @param #POINT_VEC3 TargetPointVec3 The target POINT_VEC3. --- @return Dcs.DCSTypes#Distance Distance The distance in meters. -function POINT_VEC3:Get3DDistance( TargetPointVec3 ) - local TargetVec3 = TargetPointVec3:GetVec3() - local SourceVec3 = self:GetVec3() - return ( ( TargetVec3.x - SourceVec3.x ) ^ 2 + ( TargetVec3.y - SourceVec3.y ) ^ 2 + ( TargetVec3.z - SourceVec3.z ) ^ 2 ) ^ 0.5 -end - ---- Provides a Bearing / Range string --- @param #POINT_VEC3 self --- @param #number AngleRadians The angle in randians --- @param #number Distance The distance --- @return #string The BR Text -function POINT_VEC3:GetBRText( AngleRadians, Distance ) - - AngleRadians = UTILS.Round( UTILS.ToDegree( AngleRadians ), 0 ) - if self:IsMetric() then - Distance = UTILS.Round( Distance / 1000, 2 ) - else - Distance = UTILS.Round( UTILS.MetersToNM( Distance ), 2 ) + self = self:New( Vec3.x, Vec3.y, Vec3.z ) + self:F2( self ) + return self end - local s = string.format( '%03d', AngleRadians ) .. ' for ' .. Distance - s = s .. self:GetAltitudeText() -- When the POINT is a VEC2, there will be no altitude shown. - - return s -end - - ---- Return the altitude text of the POINT_VEC3. --- @param #POINT_VEC3 self --- @return #string Altitude text. -function POINT_VEC3:GetAltitudeText() - if self:IsMetric() then - return ' at ' .. UTILS.Round( self:GetY(), 0 ) - else - return ' at ' .. UTILS.Round( UTILS.MetersToFeet( self:GetY() ), 0 ) + --- Return the coordinates of the POINT_VEC3 in Vec3 format. + -- @param #POINT_VEC3 self + -- @return Dcs.DCSTypes#Vec3 The Vec3 coodinate. + function POINT_VEC3:GetVec3() + return { x = self.x, y = self.y, z = self.z } end -end ---- Sets the POINT_VEC3 metric or NM. --- @param #POINT_VEC3 self --- @param #boolean Metric true means metric, false means NM. -function POINT_VEC3:SetMetric( Metric ) - self.Metric = Metric -end + --- Return the coordinates of the POINT_VEC3 in Vec2 format. + -- @param #POINT_VEC3 self + -- @return Dcs.DCSTypes#Vec2 The Vec2 coodinate. + function POINT_VEC3:GetVec2() + return { x = self.x, y = self.z } + end ---- Gets if the POINT_VEC3 is metric or NM. --- @param #POINT_VEC3 self --- @return #boolean Metric true means metric, false means NM. -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 Dcs.DCSTypes#Distance Distance The Distance to be added in meters. --- @param Dcs.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 + --- Return the x coordinate of the POINT_VEC3. + -- @param #POINT_VEC3 self + -- @return #number The x coodinate. + function POINT_VEC3:GetX() + return self.x + end + + --- Return the y coordinate of the POINT_VEC3. + -- @param #POINT_VEC3 self + -- @return #number The y coodinate. + function POINT_VEC3:GetY() + return self.y + end + + --- Return the z coordinate of the POINT_VEC3. + -- @param #POINT_VEC3 self + -- @return #number The z coodinate. + function POINT_VEC3:GetZ() + return self.z + end + + --- Set the x coordinate of the POINT_VEC3. + -- @param #POINT_VEC3 self + -- @param #number x The x coordinate. + -- @return #POINT_VEC3 + function POINT_VEC3:SetX( x ) + self.x = x + return self + end + + --- Set the y coordinate of the POINT_VEC3. + -- @param #POINT_VEC3 self + -- @param #number y The y coordinate. + -- @return #POINT_VEC3 + function POINT_VEC3:SetY( y ) + self.y = y + return self + end + + --- Set the z coordinate of the POINT_VEC3. + -- @param #POINT_VEC3 self + -- @param #number z The z coordinate. + -- @return #POINT_VEC3 + function POINT_VEC3:SetZ( z ) + self.z = z + return self + end + + --- Add to the x coordinate of the POINT_VEC3. + -- @param #POINT_VEC3 self + -- @param #number x The x coordinate value to add to the current x coodinate. + -- @return #POINT_VEC3 + function POINT_VEC3:AddX( x ) + self.x = self.x + x + return self + end + + --- Add to the y coordinate of the POINT_VEC3. + -- @param #POINT_VEC3 self + -- @param #number y The y coordinate value to add to the current y coodinate. + -- @return #POINT_VEC3 + function POINT_VEC3:AddY( y ) + self.y = self.y + y + return self + end + + --- Add to the z coordinate of the POINT_VEC3. + -- @param #POINT_VEC3 self + -- @param #number z The z coordinate value to add to the current z coodinate. + -- @return #POINT_VEC3 + function POINT_VEC3:AddZ( z ) + self.z = self.z +z + return self + end + + --- Return a random Vec2 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#Vec2 Vec2 + function POINT_VEC3: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_VEC3. + -- @param #POINT_VEC3 self + -- @param Dcs.DCSTypes#Distance OuterRadius + -- @param Dcs.DCSTypes#Distance InnerRadius + -- @return #POINT_VEC2 + function POINT_VEC3:GetRandomPointVec2InRadius( OuterRadius, InnerRadius ) + self:F2( { OuterRadius, InnerRadius } ) + + return POINT_VEC2:NewFromVec2( self:GetRandomVec2InRadius( OuterRadius, InnerRadius ) ) + 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 + -- @param Dcs.DCSTypes#Distance InnerRadius + -- @return #POINT_VEC3 + function POINT_VEC3:GetRandomPointVec3InRadius( OuterRadius, InnerRadius ) + + return POINT_VEC3:NewFromVec3( self:GetRandomVec3InRadius( OuterRadius, InnerRadius ) ) + end + + + --- Return a direction vector Vec3 from POINT_VEC3 to the POINT_VEC3. + -- @param #POINT_VEC3 self + -- @param #POINT_VEC3 TargetPointVec3 The target POINT_VEC3. + -- @return Dcs.DCSTypes#Vec3 DirectionVec3 The direction vector in Vec3 format. + function POINT_VEC3:GetDirectionVec3( TargetPointVec3 ) + return { x = TargetPointVec3:GetX() - self:GetX(), y = TargetPointVec3:GetY() - self:GetY(), z = TargetPointVec3:GetZ() - self:GetZ() } + end + + --- Get a correction in radians of the real magnetic north of the POINT_VEC3. + -- @param #POINT_VEC3 self + -- @return #number CorrectionRadians The correction in radians. + function POINT_VEC3:GetNorthCorrectionRadians() + local TargetVec3 = self:GetVec3() + local lat, lon = coord.LOtoLL(TargetVec3) + local north_posit = coord.LLtoLO(lat + 1, lon) + return math.atan2( north_posit.z - TargetVec3.z, north_posit.x - TargetVec3.x ) + end + + + --- Return an angle in radians from the POINT_VEC3 using a direction vector in Vec3 format. + -- @param #POINT_VEC3 self + -- @param Dcs.DCSTypes#Vec3 DirectionVec3 The direction vector in Vec3 format. + -- @return #number DirectionRadians The angle in radians. + function POINT_VEC3:GetAngleRadians( DirectionVec3 ) + local DirectionRadians = math.atan2( DirectionVec3.z, DirectionVec3.x ) + --DirectionRadians = DirectionRadians + self:GetNorthCorrectionRadians() + if DirectionRadians < 0 then + DirectionRadians = DirectionRadians + 2 * math.pi -- put dir in range of 0 to 2*pi ( the full circle ) + end + return DirectionRadians + end + + --- Return an angle in degrees from the POINT_VEC3 using a direction vector in Vec3 format. + -- @param #POINT_VEC3 self + -- @param Dcs.DCSTypes#Vec3 DirectionVec3 The direction vector in Vec3 format. + -- @return #number DirectionRadians The angle in degrees. + function POINT_VEC3:GetAngleDegrees( DirectionVec3 ) + local AngleRadians = self:GetAngleRadians(DirectionVec3) + local Angle = UTILS.ToDegree( AngleRadians ) + return Angle + end + + + --- Return the 2D distance in meters between the target POINT_VEC3 and the POINT_VEC3. + -- @param #POINT_VEC3 self + -- @param #POINT_VEC3 TargetPointVec3 The target POINT_VEC3. + -- @return Dcs.DCSTypes#Distance Distance The distance in meters. + function POINT_VEC3:Get2DDistance( TargetPointVec3 ) + local TargetVec3 = TargetPointVec3:GetVec3() + local SourceVec3 = self:GetVec3() + return ( ( TargetVec3.x - SourceVec3.x ) ^ 2 + ( TargetVec3.z - SourceVec3.z ) ^ 2 ) ^ 0.5 + end + + --- Return the 3D distance in meters between the target POINT_VEC3 and the POINT_VEC3. + -- @param #POINT_VEC3 self + -- @param #POINT_VEC3 TargetPointVec3 The target POINT_VEC3. + -- @return Dcs.DCSTypes#Distance Distance The distance in meters. + function POINT_VEC3:Get3DDistance( TargetPointVec3 ) + local TargetVec3 = TargetPointVec3:GetVec3() + local SourceVec3 = self:GetVec3() + return ( ( TargetVec3.x - SourceVec3.x ) ^ 2 + ( TargetVec3.y - SourceVec3.y ) ^ 2 + ( TargetVec3.z - SourceVec3.z ) ^ 2 ) ^ 0.5 + end + + --- Provides a Bearing / Range string + -- @param #POINT_VEC3 self + -- @param #number AngleRadians The angle in randians + -- @param #number Distance The distance + -- @return #string The BR Text + function POINT_VEC3:GetBRText( AngleRadians, Distance ) + + AngleRadians = UTILS.Round( UTILS.ToDegree( AngleRadians ), 0 ) + if self:IsMetric() then + Distance = UTILS.Round( Distance / 1000, 2 ) + else + Distance = UTILS.Round( UTILS.MetersToNM( Distance ), 2 ) + end + + local s = string.format( '%03d', AngleRadians ) .. ' for ' .. Distance + + s = s .. self:GetAltitudeText() -- When the POINT is a VEC2, there will be no altitude shown. + + return s + end + + + --- Return the altitude text of the POINT_VEC3. + -- @param #POINT_VEC3 self + -- @return #string Altitude text. + function POINT_VEC3:GetAltitudeText() + if self:IsMetric() then + return ' at ' .. UTILS.Round( self:GetY(), -3 ) + else + return ' at ' .. UTILS.Round( UTILS.MetersToFeet( self:GetY() ), 0 ) + end + end + + --- Sets the POINT_VEC3 metric or NM. + -- @param #POINT_VEC3 self + -- @param #boolean Metric true means metric, false means NM. + function POINT_VEC3:SetMetric( Metric ) + self.Metric = Metric + end + + --- Gets if the POINT_VEC3 is metric or NM. + -- @param #POINT_VEC3 self + -- @return #boolean Metric true means metric, false means NM. + 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 Dcs.DCSTypes#Distance Distance The Distance to be added in meters. + -- @param Dcs.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 ---- Build an air type route point. --- @param #POINT_VEC3 self --- @param #POINT_VEC3.RoutePointAltType AltType The altitude type. --- @param #POINT_VEC3.RoutePointType Type The route point type. --- @param #POINT_VEC3.RoutePointAction Action The route point action. --- @param Dcs.DCSTypes#Speed Speed Airspeed in km/h. --- @param #boolean SpeedLocked true means the speed is locked. --- @return #table The route point. -function POINT_VEC3:RoutePointAir( AltType, Type, Action, Speed, SpeedLocked ) - self:F2( { AltType, Type, Action, Speed, SpeedLocked } ) + --- Build an air type route point. + -- @param #POINT_VEC3 self + -- @param #POINT_VEC3.RoutePointAltType AltType The altitude type. + -- @param #POINT_VEC3.RoutePointType Type The route point type. + -- @param #POINT_VEC3.RoutePointAction Action The route point action. + -- @param Dcs.DCSTypes#Speed Speed Airspeed in km/h. + -- @param #boolean SpeedLocked true means the speed is locked. + -- @return #table The route point. + function POINT_VEC3:RoutePointAir( AltType, Type, Action, Speed, SpeedLocked ) + self:F2( { AltType, Type, Action, Speed, SpeedLocked } ) - local RoutePoint = {} - RoutePoint.x = self.x - RoutePoint.y = self.z - RoutePoint.alt = self.y - RoutePoint.alt_type = AltType - - RoutePoint.type = Type - RoutePoint.action = Action + local RoutePoint = {} + RoutePoint.x = self.x + RoutePoint.y = self.z + RoutePoint.alt = self.y + RoutePoint.alt_type = AltType - RoutePoint.speed = Speed / 3.6 - RoutePoint.speed_locked = true - --- ["task"] = --- { --- ["id"] = "ComboTask", --- ["params"] = --- { --- ["tasks"] = --- { --- }, -- end of ["tasks"] --- }, -- end of ["params"] --- }, -- end of ["task"] + RoutePoint.type = Type + RoutePoint.action = Action + + RoutePoint.speed = Speed / 3.6 + RoutePoint.speed_locked = true + + -- ["task"] = + -- { + -- ["id"] = "ComboTask", + -- ["params"] = + -- { + -- ["tasks"] = + -- { + -- }, -- end of ["tasks"] + -- }, -- end of ["params"] + -- }, -- end of ["task"] - RoutePoint.task = {} - RoutePoint.task.id = "ComboTask" - RoutePoint.task.params = {} - RoutePoint.task.params.tasks = {} - - - return RoutePoint -end - ---- Build an ground type route point. --- @param #POINT_VEC3 self --- @param Dcs.DCSTypes#Speed Speed Speed in km/h. --- @param #POINT_VEC3.RoutePointAction Formation The route point Formation. --- @return #table The route point. -function POINT_VEC3:RoutePointGround( Speed, Formation ) - self:F2( { Formation, Speed } ) - - local RoutePoint = {} - RoutePoint.x = self.x - RoutePoint.y = self.z - - RoutePoint.action = Formation or "" - - - RoutePoint.speed = Speed / 3.6 - RoutePoint.speed_locked = true - --- ["task"] = --- { --- ["id"] = "ComboTask", --- ["params"] = --- { --- ["tasks"] = --- { --- }, -- end of ["tasks"] --- }, -- end of ["params"] --- }, -- end of ["task"] + RoutePoint.task = {} + RoutePoint.task.id = "ComboTask" + RoutePoint.task.params = {} + RoutePoint.task.params.tasks = {} - RoutePoint.task = {} - RoutePoint.task.id = "ComboTask" - RoutePoint.task.params = {} - RoutePoint.task.params.tasks = {} - - - return RoutePoint -end + return RoutePoint + end ---- Creates an explosion at the point of a certain intensity. --- @param #POINT_VEC3 self --- @param #number ExplosionIntensity -function POINT_VEC3:Explosion( ExplosionIntensity ) - self:F2( { ExplosionIntensity } ) - trigger.action.explosion( self:GetVec3(), ExplosionIntensity ) -end + --- Build an ground type route point. + -- @param #POINT_VEC3 self + -- @param Dcs.DCSTypes#Speed Speed Speed in km/h. + -- @param #POINT_VEC3.RoutePointAction Formation The route point Formation. + -- @return #table The route point. + function POINT_VEC3:RoutePointGround( Speed, Formation ) + self:F2( { Formation, Speed } ) ---- Creates an illumination bomb at the point. --- @param #POINT_VEC3 self -function POINT_VEC3:IlluminationBomb() - self:F2() - trigger.action.illuminationBomb( self:GetVec3() ) -end + local RoutePoint = {} + RoutePoint.x = self.x + RoutePoint.y = self.z + + RoutePoint.action = Formation or "" ---- Smokes the point in a color. --- @param #POINT_VEC3 self --- @param Utilities.Utils#SMOKECOLOR SmokeColor -function POINT_VEC3:Smoke( SmokeColor ) - self:F2( { SmokeColor } ) - trigger.action.smoke( self:GetVec3(), SmokeColor ) -end + RoutePoint.speed = Speed / 3.6 + RoutePoint.speed_locked = true ---- Smoke the POINT_VEC3 Green. --- @param #POINT_VEC3 self -function POINT_VEC3:SmokeGreen() - self:F2() - self:Smoke( SMOKECOLOR.Green ) -end + -- ["task"] = + -- { + -- ["id"] = "ComboTask", + -- ["params"] = + -- { + -- ["tasks"] = + -- { + -- }, -- end of ["tasks"] + -- }, -- end of ["params"] + -- }, -- end of ["task"] ---- Smoke the POINT_VEC3 Red. --- @param #POINT_VEC3 self -function POINT_VEC3:SmokeRed() - self:F2() - self:Smoke( SMOKECOLOR.Red ) -end ---- Smoke the POINT_VEC3 White. --- @param #POINT_VEC3 self -function POINT_VEC3:SmokeWhite() - self:F2() - self:Smoke( SMOKECOLOR.White ) -end + RoutePoint.task = {} + RoutePoint.task.id = "ComboTask" + RoutePoint.task.params = {} + RoutePoint.task.params.tasks = {} ---- Smoke the POINT_VEC3 Orange. --- @param #POINT_VEC3 self -function POINT_VEC3:SmokeOrange() - self:F2() - self:Smoke( SMOKECOLOR.Orange ) -end ---- Smoke the POINT_VEC3 Blue. --- @param #POINT_VEC3 self -function POINT_VEC3:SmokeBlue() - self:F2() - self:Smoke( SMOKECOLOR.Blue ) -end + return RoutePoint + end ---- Flares the point in a color. --- @param #POINT_VEC3 self --- @param Utilities.Utils#FLARECOLOR FlareColor --- @param Dcs.DCSTypes#Azimuth (optional) Azimuth The azimuth of the flare direction. The default azimuth is 0. -function POINT_VEC3:Flare( FlareColor, Azimuth ) - self:F2( { FlareColor } ) - trigger.action.signalFlare( self:GetVec3(), FlareColor, Azimuth and Azimuth or 0 ) -end + --- Creates an explosion at the point of a certain intensity. + -- @param #POINT_VEC3 self + -- @param #number ExplosionIntensity + function POINT_VEC3:Explosion( ExplosionIntensity ) + self:F2( { ExplosionIntensity } ) + trigger.action.explosion( self:GetVec3(), ExplosionIntensity ) + end ---- Flare the POINT_VEC3 White. --- @param #POINT_VEC3 self --- @param Dcs.DCSTypes#Azimuth (optional) Azimuth The azimuth of the flare direction. The default azimuth is 0. -function POINT_VEC3:FlareWhite( Azimuth ) - self:F2( Azimuth ) - self:Flare( FLARECOLOR.White, Azimuth ) -end + --- Creates an illumination bomb at the point. + -- @param #POINT_VEC3 self + function POINT_VEC3:IlluminationBomb() + self:F2() + trigger.action.illuminationBomb( self:GetVec3() ) + end ---- Flare the POINT_VEC3 Yellow. --- @param #POINT_VEC3 self --- @param Dcs.DCSTypes#Azimuth (optional) Azimuth The azimuth of the flare direction. The default azimuth is 0. -function POINT_VEC3:FlareYellow( Azimuth ) - self:F2( Azimuth ) - self:Flare( FLARECOLOR.Yellow, Azimuth ) -end ---- Flare the POINT_VEC3 Green. --- @param #POINT_VEC3 self --- @param Dcs.DCSTypes#Azimuth (optional) Azimuth The azimuth of the flare direction. The default azimuth is 0. -function POINT_VEC3:FlareGreen( Azimuth ) - self:F2( Azimuth ) - self:Flare( FLARECOLOR.Green, Azimuth ) -end + --- Smokes the point in a color. + -- @param #POINT_VEC3 self + -- @param Utilities.Utils#SMOKECOLOR SmokeColor + function POINT_VEC3:Smoke( SmokeColor ) + self:F2( { SmokeColor } ) + trigger.action.smoke( self:GetVec3(), SmokeColor ) + end ---- Flare the POINT_VEC3 Red. --- @param #POINT_VEC3 self -function POINT_VEC3:FlareRed( Azimuth ) - self:F2( Azimuth ) - self:Flare( FLARECOLOR.Red, Azimuth ) -end + --- Smoke the POINT_VEC3 Green. + -- @param #POINT_VEC3 self + function POINT_VEC3:SmokeGreen() + self:F2() + self:Smoke( SMOKECOLOR.Green ) + end ---- Returns if a PointVec3 has Line of Sight (LOS) with the ToPointVec3. --- @param #POINT_VEC3 self --- @param #POINT_VEC3 ToPointVec3 --- @return #boolean true If the ToPointVec3 has LOS with the PointVec3, otherwise false. -function POINT_VEC3:IsLOS( ToPointVec3 ) --R2.1 + --- Smoke the POINT_VEC3 Red. + -- @param #POINT_VEC3 self + function POINT_VEC3:SmokeRed() + self:F2() + self:Smoke( SMOKECOLOR.Red ) + end - -- Measurement of visibility should not be from the ground, so Adding a hypotethical 2 meters to each PointVec3. - local FromVec3 = self:GetVec3() - FromVec3.y = FromVec3.y + 2 - - local ToVec3 = ToPointVec3:GetVec3() - ToVec3.y = ToVec3.y + 2 - - local IsLOS = land.isVisible( FromVec3, ToVec3 ) + --- Smoke the POINT_VEC3 White. + -- @param #POINT_VEC3 self + function POINT_VEC3:SmokeWhite() + self:F2() + self:Smoke( SMOKECOLOR.White ) + end - return IsLOS -end + --- Smoke the POINT_VEC3 Orange. + -- @param #POINT_VEC3 self + function POINT_VEC3:SmokeOrange() + self:F2() + self:Smoke( SMOKECOLOR.Orange ) + end + + --- Smoke the POINT_VEC3 Blue. + -- @param #POINT_VEC3 self + function POINT_VEC3:SmokeBlue() + self:F2() + self:Smoke( SMOKECOLOR.Blue ) + end + + --- Flares the point in a color. + -- @param #POINT_VEC3 self + -- @param Utilities.Utils#FLARECOLOR FlareColor + -- @param Dcs.DCSTypes#Azimuth (optional) Azimuth The azimuth of the flare direction. The default azimuth is 0. + function POINT_VEC3:Flare( FlareColor, Azimuth ) + self:F2( { FlareColor } ) + trigger.action.signalFlare( self:GetVec3(), FlareColor, Azimuth and Azimuth or 0 ) + end + + --- Flare the POINT_VEC3 White. + -- @param #POINT_VEC3 self + -- @param Dcs.DCSTypes#Azimuth (optional) Azimuth The azimuth of the flare direction. The default azimuth is 0. + function POINT_VEC3:FlareWhite( Azimuth ) + self:F2( Azimuth ) + self:Flare( FLARECOLOR.White, Azimuth ) + end + + --- Flare the POINT_VEC3 Yellow. + -- @param #POINT_VEC3 self + -- @param Dcs.DCSTypes#Azimuth (optional) Azimuth The azimuth of the flare direction. The default azimuth is 0. + function POINT_VEC3:FlareYellow( Azimuth ) + self:F2( Azimuth ) + self:Flare( FLARECOLOR.Yellow, Azimuth ) + end + + --- Flare the POINT_VEC3 Green. + -- @param #POINT_VEC3 self + -- @param Dcs.DCSTypes#Azimuth (optional) Azimuth The azimuth of the flare direction. The default azimuth is 0. + function POINT_VEC3:FlareGreen( Azimuth ) + self:F2( Azimuth ) + self:Flare( FLARECOLOR.Green, Azimuth ) + end + + --- Flare the POINT_VEC3 Red. + -- @param #POINT_VEC3 self + function POINT_VEC3:FlareRed( Azimuth ) + self:F2( Azimuth ) + self:Flare( FLARECOLOR.Red, Azimuth ) + end + + --- Returns if a PointVec3 has Line of Sight (LOS) with the ToPointVec3. + -- @param #POINT_VEC3 self + -- @param #POINT_VEC3 ToPointVec3 + -- @return #boolean true If the ToPointVec3 has LOS with the PointVec3, otherwise false. + function POINT_VEC3:IsLOS( ToPointVec3 ) --R2.1 + + -- Measurement of visibility should not be from the ground, so Adding a hypotethical 2 meters to each PointVec3. + local FromVec3 = self:GetVec3() + FromVec3.y = FromVec3.y + 2 + + local ToVec3 = ToPointVec3:GetVec3() + ToVec3.y = ToVec3.y + 2 + + local IsLOS = land.isVisible( FromVec3, ToVec3 ) + + return IsLOS + end end @@ -833,209 +835,206 @@ do -- POINT_VEC2 ---- POINT_VEC2 constructor. --- @param #POINT_VEC2 self --- @param Dcs.DCSTypes#Distance x The x coordinate of the Vec3 point, pointing to the North. --- @param Dcs.DCSTypes#Distance y The y coordinate of the Vec3 point, pointing to the Right. --- @param Dcs.DCSTypes#Distance LandHeightAdd (optional) The default height if required to be evaluated will be the land height of the x, y coordinate. You can specify an extra height to be added to the land height. --- @return Core.Point#POINT_VEC2 -function POINT_VEC2:New( x, y, LandHeightAdd ) + --- POINT_VEC2 constructor. + -- @param #POINT_VEC2 self + -- @param Dcs.DCSTypes#Distance x The x coordinate of the Vec3 point, pointing to the North. + -- @param Dcs.DCSTypes#Distance y The y coordinate of the Vec3 point, pointing to the Right. + -- @param Dcs.DCSTypes#Distance LandHeightAdd (optional) The default height if required to be evaluated will be the land height of the x, y coordinate. You can specify an extra height to be added to the land height. + -- @return Core.Point#POINT_VEC2 + function POINT_VEC2:New( x, y, LandHeightAdd ) - local LandHeight = land.getHeight( { ["x"] = x, ["y"] = y } ) - - LandHeightAdd = LandHeightAdd or 0 - LandHeight = LandHeight + LandHeightAdd - - self = BASE:Inherit( self, POINT_VEC3:New( x, LandHeight, y ) ) - self:F2( self ) - - return self -end + local LandHeight = land.getHeight( { ["x"] = x, ["y"] = y } ) ---- Create a new POINT_VEC2 object from Vec2 coordinates. --- @param #POINT_VEC2 self --- @param Dcs.DCSTypes#Vec2 Vec2 The Vec2 point. --- @return Core.Point#POINT_VEC2 self -function POINT_VEC2:NewFromVec2( Vec2, LandHeightAdd ) + LandHeightAdd = LandHeightAdd or 0 + LandHeight = LandHeight + LandHeightAdd - local LandHeight = land.getHeight( Vec2 ) + self = BASE:Inherit( self, POINT_VEC3:New( x, LandHeight, y ) ) + self:F2( self ) - LandHeightAdd = LandHeightAdd or 0 - LandHeight = LandHeight + LandHeightAdd - - self = BASE:Inherit( self, POINT_VEC3:New( Vec2.x, LandHeight, Vec2.y ) ) - self:F2( self ) + return self + end - return self -end + --- Create a new POINT_VEC2 object from Vec2 coordinates. + -- @param #POINT_VEC2 self + -- @param Dcs.DCSTypes#Vec2 Vec2 The Vec2 point. + -- @return Core.Point#POINT_VEC2 self + function POINT_VEC2:NewFromVec2( Vec2, LandHeightAdd ) ---- Create a new POINT_VEC2 object from Vec3 coordinates. --- @param #POINT_VEC2 self --- @param Dcs.DCSTypes#Vec3 Vec3 The Vec3 point. --- @return Core.Point#POINT_VEC2 self -function POINT_VEC2:NewFromVec3( Vec3 ) + local LandHeight = land.getHeight( Vec2 ) - local self = BASE:Inherit( self, BASE:New() ) - local Vec2 = { x = Vec3.x, y = Vec3.z } + LandHeightAdd = LandHeightAdd or 0 + LandHeight = LandHeight + LandHeightAdd - local LandHeight = land.getHeight( Vec2 ) - - self = BASE:Inherit( self, POINT_VEC3:New( Vec2.x, LandHeight, Vec2.y ) ) - self:F2( self ) + self = BASE:Inherit( self, POINT_VEC3:New( Vec2.x, LandHeight, Vec2.y ) ) + self:F2( self ) - return self -end + return self + end ---- Return the x coordinate of the POINT_VEC2. --- @param #POINT_VEC2 self --- @return #number The x coodinate. -function POINT_VEC2:GetX() - return self.x -end + --- Create a new POINT_VEC2 object from Vec3 coordinates. + -- @param #POINT_VEC2 self + -- @param Dcs.DCSTypes#Vec3 Vec3 The Vec3 point. + -- @return Core.Point#POINT_VEC2 self + function POINT_VEC2:NewFromVec3( Vec3 ) ---- Return the y coordinate of the POINT_VEC2. --- @param #POINT_VEC2 self --- @return #number The y coodinate. -function POINT_VEC2:GetY() - return self.z -end + local self = BASE:Inherit( self, BASE:New() ) ---- Return the altitude (height) of the land at the POINT_VEC2. --- @param #POINT_VEC2 self --- @return #number The land altitude. -function POINT_VEC2:GetAlt() - return land.getHeight( { x = self.x, y = self.z } ) -end + self = BASE:Inherit( self, POINT_VEC3:New( Vec3.x, Vec3.y, Vec3.z ) ) + self:F2( self ) ---- Return Return the Lat(itude) coordinate of the POINT_VEC2 (ie: (parent)POINT_VEC3.x). --- @param #POINT_VEC2 self --- @return #number The x coodinate. -function POINT_VEC2:GetLat() - return self.x -end + return self + end ---- Return the Lon(gitude) coordinate of the POINT_VEC2 (ie: (parent)POINT_VEC3.z). --- @param #POINT_VEC2 self --- @return #number The y coodinate. -function POINT_VEC2:GetLon() - return self.z -end + --- Return the x coordinate of the POINT_VEC2. + -- @param #POINT_VEC2 self + -- @return #number The x coodinate. + function POINT_VEC2:GetX() + return self.x + end ---- Set the x coordinate of the POINT_VEC2. --- @param #POINT_VEC2 self --- @param #number x The x coordinate. --- @return #POINT_VEC2 -function POINT_VEC2:SetX( x ) - self.x = x - return self -end + --- Return the y coordinate of the POINT_VEC2. + -- @param #POINT_VEC2 self + -- @return #number The y coodinate. + function POINT_VEC2:GetY() + return self.z + end ---- Set the y coordinate of the POINT_VEC2. --- @param #POINT_VEC2 self --- @param #number y The y coordinate. --- @return #POINT_VEC2 -function POINT_VEC2:SetY( y ) - self.z = y - return self -end + --- Return the altitude (height) of the land at the POINT_VEC2. + -- @param #POINT_VEC2 self + -- @return #number The land altitude. + function POINT_VEC2:GetAlt() + return land.getHeight( { x = self.x, y = self.z } ) + end ---- Set the Lat(itude) coordinate of the POINT_VEC2 (ie: POINT_VEC3.x). --- @param #POINT_VEC2 self --- @param #number x The x coordinate. --- @return #POINT_VEC2 -function POINT_VEC2:SetLat( x ) - self.x = x - return self -end + --- Return Return the Lat(itude) coordinate of the POINT_VEC2 (ie: (parent)POINT_VEC3.x). + -- @param #POINT_VEC2 self + -- @return #number The x coodinate. + function POINT_VEC2:GetLat() + return self.x + end ---- Set the altitude of the POINT_VEC2. --- @param #POINT_VEC2 self --- @param #number Altitude The land altitude. If nothing (nil) is given, then the current land altitude is set. --- @return #POINT_VEC2 -function POINT_VEC2:SetAlt( Altitude ) - self.y = Altitude or land.getHeight( { x = self.x, y = self.z } ) - return self -end + --- Return the Lon(gitude) coordinate of the POINT_VEC2 (ie: (parent)POINT_VEC3.z). + -- @param #POINT_VEC2 self + -- @return #number The y coodinate. + function POINT_VEC2:GetLon() + return self.z + end ---- Set the Lon(gitude) coordinate of the POINT_VEC2 (ie: POINT_VEC3.z). --- @param #POINT_VEC2 self --- @param #number y The y coordinate. --- @return #POINT_VEC2 -function POINT_VEC2:SetLon( z ) - self.z = z - return self -end + --- Set the x coordinate of the POINT_VEC2. + -- @param #POINT_VEC2 self + -- @param #number x The x coordinate. + -- @return #POINT_VEC2 + function POINT_VEC2:SetX( x ) + self.x = x + return self + end ---- Add to the x coordinate of the POINT_VEC2. --- @param #POINT_VEC2 self --- @param #number x The x coordinate. --- @return #POINT_VEC2 -function POINT_VEC2:AddX( x ) - self.x = self.x + x - return self -end + --- Set the y coordinate of the POINT_VEC2. + -- @param #POINT_VEC2 self + -- @param #number y The y coordinate. + -- @return #POINT_VEC2 + function POINT_VEC2:SetY( y ) + self.z = y + return self + end ---- Add to the y coordinate of the POINT_VEC2. --- @param #POINT_VEC2 self --- @param #number y The y coordinate. --- @return #POINT_VEC2 -function POINT_VEC2:AddY( y ) - self.z = self.z + y - return self -end + --- Set the Lat(itude) coordinate of the POINT_VEC2 (ie: POINT_VEC3.x). + -- @param #POINT_VEC2 self + -- @param #number x The x coordinate. + -- @return #POINT_VEC2 + function POINT_VEC2:SetLat( x ) + self.x = x + return self + end ---- Add to the current land height an altitude. --- @param #POINT_VEC2 self --- @param #number Altitude The Altitude to add. If nothing (nil) is given, then the current land altitude is set. --- @return #POINT_VEC2 -function POINT_VEC2:AddAlt( Altitude ) - self.y = land.getHeight( { x = self.x, y = self.z } ) + Altitude or 0 - return self -end + --- Set the altitude of the POINT_VEC2. + -- @param #POINT_VEC2 self + -- @param #number Altitude The land altitude. If nothing (nil) is given, then the current land altitude is set. + -- @return #POINT_VEC2 + function POINT_VEC2:SetAlt( Altitude ) + self.y = Altitude or land.getHeight( { x = self.x, y = self.z } ) + return self + end + + --- Set the Lon(gitude) coordinate of the POINT_VEC2 (ie: POINT_VEC3.z). + -- @param #POINT_VEC2 self + -- @param #number y The y coordinate. + -- @return #POINT_VEC2 + function POINT_VEC2:SetLon( z ) + self.z = z + return self + end + + --- Add to the x coordinate of the POINT_VEC2. + -- @param #POINT_VEC2 self + -- @param #number x The x coordinate. + -- @return #POINT_VEC2 + function POINT_VEC2:AddX( x ) + self.x = self.x + x + return self + end + + --- Add to the y coordinate of the POINT_VEC2. + -- @param #POINT_VEC2 self + -- @param #number y The y coordinate. + -- @return #POINT_VEC2 + function POINT_VEC2:AddY( y ) + self.z = self.z + y + return self + end + + --- Add to the current land height an altitude. + -- @param #POINT_VEC2 self + -- @param #number Altitude The Altitude to add. If nothing (nil) is given, then the current land altitude is set. + -- @return #POINT_VEC2 + function POINT_VEC2:AddAlt( Altitude ) + self.y = land.getHeight( { x = self.x, y = self.z } ) + Altitude or 0 + return self + end ---- Calculate the distance from a reference @{#POINT_VEC2}. --- @param #POINT_VEC2 self --- @param #POINT_VEC2 PointVec2Reference The reference @{#POINT_VEC2}. --- @return Dcs.DCSTypes#Distance The distance from the reference @{#POINT_VEC2} in meters. -function POINT_VEC2:DistanceFromPointVec2( PointVec2Reference ) - self:F2( PointVec2Reference ) - - local Distance = ( ( PointVec2Reference:GetX() - self:GetX() ) ^ 2 + ( PointVec2Reference:GetY() - self:GetY() ) ^2 ) ^0.5 - - self:T2( Distance ) - return Distance -end + --- Calculate the distance from a reference @{#POINT_VEC2}. + -- @param #POINT_VEC2 self + -- @param #POINT_VEC2 PointVec2Reference The reference @{#POINT_VEC2}. + -- @return Dcs.DCSTypes#Distance The distance from the reference @{#POINT_VEC2} in meters. + function POINT_VEC2:DistanceFromPointVec2( PointVec2Reference ) + self:F2( PointVec2Reference ) ---- 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 + local Distance = ( ( PointVec2Reference:GetX() - self:GetX() ) ^ 2 + ( PointVec2Reference:GetY() - self:GetY() ) ^2 ) ^0.5 + + self:T2( Distance ) + return Distance + end + + --- 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 + --- 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 @@ -1048,23 +1047,23 @@ do -- COORDINATE -- @param Dcs.DCSTypes#Distance LandHeightAdd (optional) The default height if required to be evaluated will be the land height of the x, y coordinate. You can specify an extra height to be added to the land height. -- @return Core.Point#COORDINATE function COORDINATE:New( x, y, LandHeightAdd ) --R2.1 Fixes issue #424. - + self = BASE:Inherit( self, POINT_VEC2:New( x, y, LandHeightAdd ) ) -- Core.Point#COORDINATE self:F2( self ) - + return self end - + --- Create a new COORDINATE object from Vec2 coordinates. -- @param #COORDINATE self -- @param Dcs.DCSTypes#Vec2 Vec2 The Vec2 point. -- @param Dcs.DCSTypes#Distance LandHeightAdd (optional) The default height if required to be evaluated will be the land height of the x, y coordinate. You can specify an extra height to be added to the land height. -- @return Core.Point#COORDINATE self function COORDINATE:NewFromVec2( Vec2, LandHeightAdd ) --R2.1 Fixes issue #424. - + self = BASE:Inherit( self, POINT_VEC2:NewFromVec2( Vec2, LandHeightAdd ) ) -- Core.Point#COORDINATE self:F2( self ) - + return self end @@ -1073,22 +1072,27 @@ do -- COORDINATE -- @param Dcs.DCSTypes#Vec3 Vec3 The Vec3 point. -- @return Core.Point#COORDINATE self function COORDINATE:NewFromVec3( Vec3 ) --R2.1 Fixes issue #424. - - self = BASE:Inherit( self, POINT_VEC2:NewFromVec3( Vec3 ) ) -- Core.Point#COORDINATE + + self = BASE:Inherit( self, POINT_VEC3:NewFromVec3( Vec3 ) ) -- Core.Point#COORDINATE self:F2( self ) - + return self end + function COORDINATE:SetHeading( Heading ) + self.Heading = Heading + end + + --- Return a BR string from a COORDINATE to the COORDINATE. -- @param #COORDINATE self -- @param #COORDINATE TargetCoordinate The target COORDINATE. -- @return #string The BR text. function COORDINATE:ToStringBR( TargetCoordinate ) - local DirectionVec3 = self:GetDirectionVec3( TargetCoordinate ) - local AngleRadians = self:GetAngleRadians( DirectionVec3 ) - local Distance = self:Get2DDistance( TargetCoordinate ) - return "BR: " .. self:GetBRText( AngleRadians, Distance ) + local DirectionVec3 = self:GetDirectionVec3( TargetCoordinate ) + local AngleRadians = self:GetAngleRadians( DirectionVec3 ) + local Distance = self:Get2DDistance( TargetCoordinate ) + return "BR: " .. self:GetBRText( AngleRadians, Distance ) end --- Return a BRAA string from a COORDINATE to the COORDINATE. @@ -1096,11 +1100,11 @@ do -- COORDINATE -- @param #COORDINATE TargetCoordinate The target COORDINATE. -- @return #string The BR text. function COORDINATE:ToStringBRAA( TargetCoordinate ) - local DirectionVec3 = self:GetDirectionVec3( TargetCoordinate ) - local AngleRadians = self:GetAngleRadians( DirectionVec3 ) - local Distance = self:Get2DDistance( TargetCoordinate ) - local Altitude = self:GetAltitudeText() - return "BRAA: " .. self:GetBRText( AngleRadians, Distance ) .. Altitude .. ", flanking" + local DirectionVec3 = self:GetDirectionVec3( TargetCoordinate ) + local AngleRadians = self:GetAngleRadians( DirectionVec3 ) + local Distance = self:Get2DDistance( TargetCoordinate ) + local Altitude = self:GetAltitudeText() + return "BRAA: " .. self:GetBRText( AngleRadians, Distance ) end --- Return a BULLS string from a COORDINATE to the BULLS of the coalition. @@ -1108,12 +1112,39 @@ do -- COORDINATE -- @param Dcs.DCSCoalition#coalition.side Coalition The coalition. -- @return #string The BR text. function COORDINATE:ToStringBULLS( Coalition ) - local TargetCoordinate = COORDINATE:NewFromVec3( coalition.getMainRefPoint( Coalition ) ) - local DirectionVec3 = self:GetDirectionVec3( TargetCoordinate ) - local AngleRadians = self:GetAngleRadians( DirectionVec3 ) - local Distance = self:Get2DDistance( TargetCoordinate ) - local Altitude = self:GetAltitudeText() - return "BULLS: " .. self:GetBRText( AngleRadians, Distance ) .. Altitude .. ", flanking" + local TargetCoordinate = COORDINATE:NewFromVec3( coalition.getMainRefPoint( Coalition ) ) + local DirectionVec3 = self:GetDirectionVec3( TargetCoordinate ) + local AngleRadians = self:GetAngleRadians( DirectionVec3 ) + local Distance = self:Get2DDistance( TargetCoordinate ) + local Altitude = self:GetAltitudeText() + return "BULLS: " .. self:GetBRText( AngleRadians, Distance ) + end + + --- Return an aspect string from a COORDINATE to the Angle of the object. + -- @param #COORDINATE self + -- @param #COORDINATE TargetCoordinate The target COORDINATE. + -- @return #string The Aspect string, which is Hot, Cold or Flanking. + function COORDINATE:ToStringAspect( TargetCoordinate ) + local Heading = self.Heading + local DirectionVec3 = self:GetDirectionVec3( TargetCoordinate ) + local Angle = self:GetAngleDegrees( DirectionVec3 ) + + if Heading then + local Aspect = Angle - Heading + if Aspect > -135 and Aspect <= -45 then + return "Flanking" + end + if Aspect > -45 and Aspect <= 45 then + return "Hot" + end + if Aspect > 45 and Aspect <= 135 then + return "Flanking" + end + if Aspect > 135 or Aspect <= -135 then + return "Cold" + end + end + return "" end --- Provides a Lat Lon string @@ -1122,87 +1153,87 @@ do -- COORDINATE -- @param #boolean LL_DMS true = Degrees, Minutes, Seconds; false = Degrees, Minutes -- @return #string The LL Text function COORDINATE:ToStringLL( LL_Accuracy, LL_DMS ) --R2.1 Fixes issue #424. - + LL_Accuracy = LL_Accuracy or self.LL_Accuracy LL_DMS = LL_DMS or self.LL_DMS local lat, lon = coord.LOtoLL( self:GetVec3() ) return "LL: " .. UTILS.tostringLL( lat, lon, LL_Accuracy, LL_DMS ) end - + --- Provides a MGRS string -- @param #COORDINATE self - -- @param #number MGRS_Accuracy of the 5 digit code. - -- Precision depends on the Accuracy choosen: - -- * 0 = no digits - precision level 100 km - -- * 1 = 1 digits - precision level 10 km - -- * 2 = 2 digits - precision level 1 km - -- * 3 = 3 digits - precision level 100 m + -- @param #number MGRS_Accuracy of the 5 digit code. + -- Precision depends on the Accuracy choosen: + -- * 0 = no digits - precision level 100 km + -- * 1 = 1 digits - precision level 10 km + -- * 2 = 2 digits - precision level 1 km + -- * 3 = 3 digits - precision level 100 m -- * 4 = 4 digits - precision level 10 m. -- @return #string The MGRS Text function COORDINATE:ToStringMGRS( MGRS_Accuracy ) --R2.1 Fixes issue #424. - + MGRS_Accuracy = MGRS_Accuracy or self.MGRS_Accuracy local lat, lon = coord.LOtoLL( self:GetVec3() ) local MGRS = coord.LLtoMGRS( lat, lon ) return "MGRS: " .. UTILS.tostringMGRS( MGRS, MGRS_Accuracy ) end - + --- Provides a coordinate string of the point, based on a coordinate format system: -- * Uses default settings in COORDINATE. -- * Can be overridden if for a GROUP containing x clients, a menu was selected to override the default. - -- + -- -- @param #COORDINATE self -- @return #string The coordinate Text in the configured coordinate system. function COORDINATE:ToString() --R2.1 Fixes issue #424. - + local Coordinate = COORDINATE -- Core.Point#COORDINATE - + local CoordSystem = Coordinate.System - + if CoordSystem == "LL" then return self:ToStringLL( Coordinate.LL_Accuracy, Coordinate.LL_DMS ) end - + if CoordSystem == "MGRS" then return self:ToStringMGRS( Coordinate.MGRS_Accuracy ) end - + return nil - + end - + --- @param #COORDINATE self -- @return #string The coordinate Text in the configured coordinate system. function COORDINATE:CoordinateMenu( RootMenu ) --R2.1 Fixes issue #424. - + if self.SystemMenu then self.SystemMenu:Remove() self.SystemMenu = nil - end - - self.SystemMenu = MENU_MISSION:New( "System Settings" ) - local CoordinateMenu = MENU_MISSION:New( "Coordinates", self.SystemMenu ) + end - local Coordinate = COORDINATE - - if Coordinate.System == "LL" then - MENU_MISSION_COMMAND:New( "Activate MGRS", CoordinateMenu, Coordinate.MenuSystem, Coordinate, "MGRS" ) - MENU_MISSION_COMMAND:New( "LL Accuracy 1", CoordinateMenu, Coordinate.MenuLL_Accuracy, Coordinate, 1 ) - MENU_MISSION_COMMAND:New( "LL Accuracy 2", CoordinateMenu, Coordinate.MenuLL_Accuracy, Coordinate, 2 ) - MENU_MISSION_COMMAND:New( "LL Accuracy 3", CoordinateMenu, Coordinate.MenuLL_Accuracy, Coordinate, 3 ) - MENU_MISSION_COMMAND:New( "LL Decimal On", CoordinateMenu, Coordinate.MenuLL_DMS, Coordinate, true ) - MENU_MISSION_COMMAND:New( "LL Decimal Off", CoordinateMenu, Coordinate.MenuLL_DMS, Coordinate, false ) - end + self.SystemMenu = MENU_MISSION:New( "System Settings" ) + local CoordinateMenu = MENU_MISSION:New( "Coordinates", self.SystemMenu ) + + local Coordinate = COORDINATE + + if Coordinate.System == "LL" then + MENU_MISSION_COMMAND:New( "Activate MGRS", CoordinateMenu, Coordinate.MenuSystem, Coordinate, "MGRS" ) + MENU_MISSION_COMMAND:New( "LL Accuracy 1", CoordinateMenu, Coordinate.MenuLL_Accuracy, Coordinate, 1 ) + MENU_MISSION_COMMAND:New( "LL Accuracy 2", CoordinateMenu, Coordinate.MenuLL_Accuracy, Coordinate, 2 ) + MENU_MISSION_COMMAND:New( "LL Accuracy 3", CoordinateMenu, Coordinate.MenuLL_Accuracy, Coordinate, 3 ) + MENU_MISSION_COMMAND:New( "LL Decimal On", CoordinateMenu, Coordinate.MenuLL_DMS, Coordinate, true ) + MENU_MISSION_COMMAND:New( "LL Decimal Off", CoordinateMenu, Coordinate.MenuLL_DMS, Coordinate, false ) + end + + if Coordinate.System == "MGRS" then + MENU_MISSION_COMMAND:New( "Activate LL", CoordinateMenu, Coordinate.MenuSystem, Coordinate, "LL" ) + MENU_MISSION_COMMAND:New( "MGRS Accuracy 1", CoordinateMenu, Coordinate.MenuMGRS_Accuracy, Coordinate, 1 ) + MENU_MISSION_COMMAND:New( "MGRS Accuracy 2", CoordinateMenu, Coordinate.MenuMGRS_Accuracy, Coordinate, 2 ) + MENU_MISSION_COMMAND:New( "MGRS Accuracy 3", CoordinateMenu, Coordinate.MenuMGRS_Accuracy, Coordinate, 3 ) + MENU_MISSION_COMMAND:New( "MGRS Accuracy 4", CoordinateMenu, Coordinate.MenuMGRS_Accuracy, Coordinate, 4 ) + MENU_MISSION_COMMAND:New( "MGRS Accuracy 5", CoordinateMenu, Coordinate.MenuMGRS_Accuracy, Coordinate, 5 ) + end - if Coordinate.System == "MGRS" then - MENU_MISSION_COMMAND:New( "Activate LL", CoordinateMenu, Coordinate.MenuSystem, Coordinate, "LL" ) - MENU_MISSION_COMMAND:New( "MGRS Accuracy 1", CoordinateMenu, Coordinate.MenuMGRS_Accuracy, Coordinate, 1 ) - MENU_MISSION_COMMAND:New( "MGRS Accuracy 2", CoordinateMenu, Coordinate.MenuMGRS_Accuracy, Coordinate, 2 ) - MENU_MISSION_COMMAND:New( "MGRS Accuracy 3", CoordinateMenu, Coordinate.MenuMGRS_Accuracy, Coordinate, 3 ) - MENU_MISSION_COMMAND:New( "MGRS Accuracy 4", CoordinateMenu, Coordinate.MenuMGRS_Accuracy, Coordinate, 4 ) - MENU_MISSION_COMMAND:New( "MGRS Accuracy 5", CoordinateMenu, Coordinate.MenuMGRS_Accuracy, Coordinate, 5 ) - end - end --- @param #COORDINATE self @@ -1216,7 +1247,7 @@ do -- COORDINATE self.LL_Accuracy = LL_Accuracy self:CoordinateMenu() end - + --- @param #COORDINATE self function COORDINATE:MenuLL_DMS( LL_DMS ) --R2.1 Fixes issue #424. self.LL_DMS = LL_DMS diff --git a/Moose Development/Moose/Functional/Detection.lua b/Moose Development/Moose/Functional/Detection.lua index dbd55b26b..f75210006 100644 --- a/Moose Development/Moose/Functional/Detection.lua +++ b/Moose Development/Moose/Functional/Detection.lua @@ -1192,7 +1192,7 @@ do -- DETECTION_BASE end DetectedItem.Set = Set or SET_UNIT:New():FilterDeads():FilterCrashes() - DetectedItem.Index = DetectedItemIndex + DetectedItem.Index = DetectedItemIndex or self.DetectedItemCount DetectedItem.ItemID = ItemPrefix .. "." .. self.DetectedItemMax DetectedItem.ID = self.DetectedItemMax DetectedItem.Removed = false @@ -1312,16 +1312,21 @@ do -- DETECTION_BASE function DETECTION_BASE:GetDetectedItemCoordinate( Index ) -- If the Zone is set, return the coordinate of the Zone. + local DetectedItemSet = self:GetDetectedSet( Index ) + local FirstUnit = DetectedItemSet:GetFirst() + local DetectedZone = self:GetDetectedItemZone( Index ) if DetectedZone then - return DetectedZone:GetCoordinate() + local Coordinate = DetectedZone:GetCoordinate() + Coordinate:SetHeading(FirstUnit:GetHeading()) + return Coordinate end -- If no Zone is set, return the coordinate of the first unit in the Set - local DetectedItemSet = self:GetDetectedSet( Index ) - local FirstUnit = DetectedItemSet:GetFirst() if FirstUnit then - return FirstUnit:GetCoordinate() + local Coordinate = FirstUnit:GetCoordinate() + FirstUnit:SetHeading(FirstUnit:GetHeading()) + return Coordinate end return nil diff --git a/Moose Development/Moose/Tasking/Task.lua b/Moose Development/Moose/Tasking/Task.lua index 6f8965951..5c95f5b8a 100644 --- a/Moose Development/Moose/Tasking/Task.lua +++ b/Moose Development/Moose/Tasking/Task.lua @@ -1404,9 +1404,7 @@ function TASK:ReportDetails( TaskGroup ) --R2.1 fixed report. Now nicely formatt if TaskInfoID == "Coordinates" then local FromCoordinate = TaskGroup:GetUnit(1):GetCoordinate() Report:Add( TaskInfoIDText ) - Report:AddIndent( TaskInfo:ToStringLL() ) - Report:AddIndent( TaskInfo:ToStringMGRS() ) - Report:AddIndent( TaskInfo:ToStringBRAA( FromCoordinate ) ) + Report:AddIndent( TaskInfo:ToStringBRAA( FromCoordinate ) .. ", " .. TaskInfo:ToStringAspect( FromCoordinate ) ) Report:AddIndent( TaskInfo:ToStringBULLS( TaskGroup:GetCoalition() ) ) else end diff --git a/Moose Development/Moose/Tasking/Task_A2A_Dispatcher.lua b/Moose Development/Moose/Tasking/Task_A2A_Dispatcher.lua index 503c8579c..a812e275b 100644 --- a/Moose Development/Moose/Tasking/Task_A2A_Dispatcher.lua +++ b/Moose Development/Moose/Tasking/Task_A2A_Dispatcher.lua @@ -73,6 +73,7 @@ do -- TASK_A2A_DISPATCHER self.Detection:FilterCategories( Unit.Category.AIRPLANE, Unit.Category.HELICOPTER ) self.Detection:InitDetectRadar( true ) + self.Detection:SetDetectionInterval(30) self:AddTransition( "Started", "Assign", "Started" ) @@ -191,6 +192,7 @@ do -- TASK_A2A_DISPATCHER Task:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ) ) Task:SetInfo( "Coordinates", Detection:GetDetectedItemCoordinate( DetectedIndex ) ) Task:SetInfo( "Changes", Detection:GetChangeText( DetectedItem ) ) + Task:SetInfo( "Object", DetectedSet:GetFirst() ) Mission:AddTask( Task ) else self:E("This should not happen") diff --git a/Moose Development/Moose/Wrapper/Positionable.lua b/Moose Development/Moose/Wrapper/Positionable.lua index fa554dad9..e33a9c392 100644 --- a/Moose Development/Moose/Wrapper/Positionable.lua +++ b/Moose Development/Moose/Wrapper/Positionable.lua @@ -149,6 +149,7 @@ function POSITIONABLE:GetCoordinate() local PositionableVec3 = self:GetPositionVec3() local PositionableCoordinate = COORDINATE:NewFromVec3( PositionableVec3 ) + PositionableCoordinate:SetHeading( self:GetHeading() ) self:T2( PositionableCoordinate ) return PositionableCoordinate