Jump to content

Problem: locating DCA flights using a series of points as border


chromium

Recommended Posts

Hello everyone,

 

As I can't figure out how to solve this issue, I'm going to ask you for a solution or an idea.

 

I have a table of VEC2 points (let's say navpoints) prepared in the ME. Those points forms a polyline, which is my coalition's FLOT. My needs is:

 

1) locating the starting and the ending point of the polyline, the extremity (can't use tag names, the navpoints name are already defined).

2) calculating the total distance of the polyline (viable and easy, but i first need "1" to have a starting point)

3) find average distance lenghs.. let's say I have 2 DCA flights to be located, I will split my polyline lenght by 3, to have 2 mean lenghts. Lets say that those 2 points are "A" and "B"

4) the biggest problem: given "A" and "B" distance from starting point on the polyline.. How could I exactly locate them in as a VEC2?

 

PS: I can't manually locate those points, cause from mission to mission the FLOT points may change. The only thing that I know is that I will be able to form a polyline with them.

 

See the attached scheme for a better comprehension.

 

 

Thanks...

Prova.pdf

ChromiumDis.png

Author of DSMC, mod to enable scenario persistency and save updated miz file

Stable version & site: https://dsmcfordcs.wordpress.com/

Openbeta: https://github.com/Chromium18/DSMC

 

The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.

Link to comment
Share on other sites

You start with an unordered set of points. To make those into a line, I would find a starting point and then subsequently add the closest point that is not already on the list.

 

To find a suitable starting point, you could just sort by X, then Y coordinate (i.e. take the top-left one).

 

Note that for a given set of points there can be several polyline interpretations that "look plausible" to the human eye (example).

 

 

Once you have an actual polyline (i.e. an ordered list of points), point (2) should be easy to solve with the vector math functions provided by MiST.

 

To solve (4), you can do something like this (untested):

function getPointOnPolyline(polyline, distance)
 local i = 1
 while distance > 0 do
   local a = polyline[i]
   local b = polyline[i+1]
   local ab_diff = mist.vec.sub(b, a)
   local ab_dist = mist.vec.mag(ab_diff)
   if distance > ab_dist then
     distance = distance - ab_dist
     i = i + 1
     continue
   end
   local direction = mist.vec.getUnitVec(ab_diff)
   return mist.vec.add(a, mist.vec.scalar_mult(direction, distance))
 end
end

 

I don't know if all the MiSt vector functions work with vec2's, you may have to convert to vec3's first.

Link to comment
Share on other sites

Thanks Ian, to be honest I'll work with VEC3 having y= 0. Said VEC2 to simplify explanation. My issue is that not always the "first point" will be the most NW or SE or SW etc.. of the set.

 

About the polyline, I won't have issue about ordering them for other reason. :).

 

But...

 

MANY THANKS for the subsequent chunk. It's kind of magic for my knowledge, but I understood it. Thanks!

ChromiumDis.png

Author of DSMC, mod to enable scenario persistency and save updated miz file

Stable version & site: https://dsmcfordcs.wordpress.com/

Openbeta: https://github.com/Chromium18/DSMC

 

The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...