Skip to content

Commit

Permalink
Update Pathline.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
funkyfranky committed Feb 8, 2023
1 parent f02b703 commit e4c8ca3
Showing 1 changed file with 40 additions and 10 deletions.
50 changes: 40 additions & 10 deletions Moose Development/Moose/Core/Pathline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
-- **Main Features:**
--
-- * Path from A to B
-- * Arbitrary number of segments
-- * Arbitrary number of points
-- * Automatically from lines drawtool
--
-- ===
Expand Down Expand Up @@ -230,26 +230,56 @@ function PATHLINE:GetCoordinats()
return vecs
end

--- Get the n-th point.
--- Get the n-th point of the pathline.
-- @param #PATHLINE self
-- @param #number n The n-th point.
-- @return #number Number of points.
function PATHLINE:GetPoint3D(n)
-- @param #number n The index of the point. Default is the first point.
-- @return #PATHLINE.Point Point.
function PATHLINE:GetPointFromIndex(n)

local N=self:GetNumberOfPoints()

n=n or 1

local vec3=nil
if n and n>=1 and n<=N then

vec3=self.point[n]
local point=nil --#PATHLINE.Point

if n>=1 and n<=N then
point=self.point[n]
else
self:E(self.lid..string.format("ERROR: No point in pathline for N=%s", tostring(n)))
end

return point
end

--- Get the 3D position of the n-th point.
-- @param #PATHLINE self
-- @param #number n The n-th point.
-- @return DCS#VEC3 Position in 3D.
function PATHLINE:GetPoint3DFromIndex(n)

local point=self:GetPointFromIndex(n)

if point then
return point.vec3
end

return vec3
return nil
end

--- Get the 2D position of the n-th point.
-- @param #PATHLINE self
-- @param #number n The n-th point.
-- @return DCS#VEC2 Position in 3D.
function PATHLINE:GetPoint2DFromIndex(n)

local point=self:GetPointFromIndex(n)

if point then
return point.vec2
end

return nil
end


--- Mark points on F10 map.
Expand Down

0 comments on commit e4c8ca3

Please sign in to comment.