mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
NAVYGROUP
- Improved heading into wind
This commit is contained in:
parent
7453a6c55d
commit
5d40091947
@ -644,6 +644,41 @@ function VECTOR:SubVec(Vec)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Calculate the dot product of this VECTOR with another vector. This function works for DCS#Vec2, DCS#Vec3, VECTOR, COORDINATE objects.
|
||||
-- @param #VECTOR self
|
||||
-- @param DCS#Vec3 Vec The other vector. Can also be a DCS#Vec2, DCS#Vec3, COORDINATE or VECTOR object.
|
||||
-- @return #number Dot product Sum_i(a[i]*b[i]). Note that this is a **scalar** and not a vector any more!
|
||||
function VECTOR:Dot(Vec)
|
||||
|
||||
local dot=self.x*Vec.x
|
||||
if Vec.z then
|
||||
dot=dot+self.y*Vec.y+self.z*Vec.z
|
||||
else
|
||||
-- Vec is 2D ==> we take its y-component for z.
|
||||
dot=dot+self.z*Vec.y
|
||||
end
|
||||
|
||||
return dot
|
||||
end
|
||||
|
||||
--- Calculate the rotation or cross product of this VECTOR with another vector. This function works for DCS#Vec2, DCS#Vec3, VECTOR, COORDINATE objects.
|
||||
-- @param #VECTOR self
|
||||
-- @param DCS#Vec3 Vec The other vector. Can also be a DCS#Vec2, DCS#Vec3, COORDINATE or VECTOR object.
|
||||
-- @return #VECTOR The cross product vector.
|
||||
function VECTOR:Rot(Vec)
|
||||
|
||||
-- TODO:
|
||||
local dot=self.x*Vec.x
|
||||
if Vec.z then
|
||||
dot=dot+self.y*Vec.y+self.z*Vec.z
|
||||
else
|
||||
-- Vec is 2D ==> we take its y-component for z.
|
||||
dot=dot+self.z*Vec.y
|
||||
end
|
||||
|
||||
return dot
|
||||
end
|
||||
|
||||
|
||||
--- Get a clone (deep copy) of this vector.
|
||||
-- @param #VECTOR self
|
||||
@ -1012,8 +1047,6 @@ function VECTOR:ArrowToAll(Vector)
|
||||
|
||||
local vec3Start=self:GetVec3()
|
||||
|
||||
|
||||
|
||||
trigger.action.arrowToAll(coalition , id, vec3Start, vec3End, color, fillColor , lineType, readOnly, "")
|
||||
|
||||
return self
|
||||
|
||||
@ -90,7 +90,7 @@ NAVYGROUP = {
|
||||
|
||||
--- NavyGroup version.
|
||||
-- @field #string version
|
||||
NAVYGROUP.version="1.0.1"
|
||||
NAVYGROUP.version="1.0.2"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO list
|
||||
@ -586,7 +586,7 @@ end
|
||||
-- @param #string stoptime Stop time, e.g. "9:00" for nine o'clock. Default 90 minutes after start time.
|
||||
-- @param #number speed Wind speed on deck in knots during turn into wind leg. Default 20 knots.
|
||||
-- @param #boolean uturn If `true` (or `nil`), carrier wil perform a U-turn and go back to where it came from before resuming its route to the next waypoint. If false, it will go directly to the next waypoint.
|
||||
-- @param #number offset Offset angle in degrees, e.g. to account for an angled runway. Default 0 deg.
|
||||
-- @param #number offset Offset angle clock-wise in degrees, *e.g.* to account for an angled runway. Default 0 deg. Use around -9.1° for US carriers.
|
||||
-- @return #NAVYGROUP.IntoWind Turn into window data table.
|
||||
function NAVYGROUP:AddTurnIntoWind(starttime, stoptime, speed, uturn, offset)
|
||||
|
||||
@ -2050,15 +2050,16 @@ end
|
||||
|
||||
--- Get wind direction and speed at current position.
|
||||
-- @param #NAVYGROUP self
|
||||
-- @param #number Altitude Altitude in meters above main sea level at which the wind is calculated. Default 18 meters.
|
||||
-- @return #number Direction the wind is blowing **from** in degrees.
|
||||
-- @return #number Wind speed in m/s.
|
||||
function NAVYGROUP:GetWind()
|
||||
function NAVYGROUP:GetWind(Altitude)
|
||||
|
||||
-- Current position of the carrier or input.
|
||||
local coord=self:GetCoordinate()
|
||||
|
||||
-- Wind direction and speed. By default at 50 meters ASL.
|
||||
local Wdir, Wspeed=coord:GetWind(50)
|
||||
-- Wind direction and speed. By default at 18 meters ASL.
|
||||
local Wdir, Wspeed=coord:GetWind(Altitude or 18)
|
||||
|
||||
return Wdir, Wspeed
|
||||
end
|
||||
@ -2103,7 +2104,7 @@ function NAVYGROUP:GetHeadingIntoWind(Offset, vdeck)
|
||||
Offset=Offset or 0
|
||||
|
||||
-- Get direction the wind is blowing from.
|
||||
local windfrom, vwind=self:GetWind()
|
||||
local windfrom, vwind=self:GetWind(18)
|
||||
|
||||
-- Convert wind speed to knots.
|
||||
vwind=UTILS.MpsToKnots(vwind)
|
||||
@ -2111,8 +2112,8 @@ function NAVYGROUP:GetHeadingIntoWind(Offset, vdeck)
|
||||
-- Wind to in knots.
|
||||
local windto=(windfrom+180)%360
|
||||
|
||||
-- Offset angle in rad.
|
||||
local alpha=math.rad(Offset)
|
||||
-- Offset angle in rad. We also define the rotation to be clock-wise, which requires a minus sign.
|
||||
local alpha=math.rad(-Offset)
|
||||
|
||||
-- Ships min/max speed.
|
||||
local Vmin=4
|
||||
@ -2130,10 +2131,10 @@ function NAVYGROUP:GetHeadingIntoWind(Offset, vdeck)
|
||||
|
||||
|
||||
-- Speed of ship so it matches the desired speed.
|
||||
local v
|
||||
local v=0
|
||||
|
||||
-- Angle wrt. to wind TO-direction
|
||||
local theta
|
||||
local theta=0
|
||||
|
||||
if vdeck>vdeckMax then
|
||||
-- Boat cannot go fast enough
|
||||
@ -2172,6 +2173,9 @@ function NAVYGROUP:GetHeadingIntoWind(Offset, vdeck)
|
||||
-- Ship heading so cross wind is min for the given wind.
|
||||
local intowind = (540 + (windto + math.deg(theta) )) % 360
|
||||
|
||||
-- Debug info.
|
||||
self:I(self.lid..string.format("Heading into Wind: vship=%.1f, vwind=%.1f, WindTo=%03d°, Theta=%03d°, Heading=%03d", v, vwind, windto, theta, intowind))
|
||||
|
||||
return intowind, v
|
||||
end
|
||||
|
||||
|
||||
@ -12664,7 +12664,7 @@ function OPSGROUP:_UpdatePosition()
|
||||
self.positionLast=self.position or self:GetVec3()
|
||||
self.headingLast=self.heading or self:GetHeading()
|
||||
self.orientXLast=self.orientX or self:GetOrientationX()
|
||||
self.velocityLast=self.velocity or self.group:GetVelocityMPS()
|
||||
self.velocityLast=self.velocity or self.group:GetVelocityMPS()
|
||||
|
||||
-- Current state.
|
||||
self.position=self:GetVec3()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user