Calculate area between lines/paths of vehicles

Hi All,



Got a bit of a problem, and after a day at work my brains run out, so wondered what peoples thoughts were.



I’ve got a simulation where I have a number of cars, with a lead car, and the rest follow it, convoy style. I’m looking at how different convoy communication approaches benefit the performance of the convoy itself.



I’ve got all the vehicle position data logged into a DB, but its generated in real time, with my jmonkey view to see whats going on, either realtime view or replay/rewind etc from the DB.



But now, for the metrics… the obvious one is to measure the deviation of the convoy vehicles from the convoy leader. But, the convoy vehicles are simulated remotely (so they could be real vehicles too), and so update at different timestamps. Otherwise, at each time step, you could just do the maths on where they are compared to the leader.



The best idea I’ve got so far, is to plot a line for the convoy leader, and thats the line they should follow. The delta between their position at that line, is the convoy deviation, sum it all up and thats the measure. At the moment I can only think of doing this graphically though… so orientate your axis in line with the lead vehicle, project a line at 90 degrees to either side, and when it collides with the line plot of where a convoy follower vehicle went, measure the distance, and at the sample, hey presto you have the distance. You could then move along the convoy leader line doing this at really small intervals, and there you go…



It seems a bit crude, but I think could work? Just wondered if anyone had any better ideas?! I thought about dumping the data out to csv and trying something in excel, but can’t think of anything there… tried thinking of some sort of monte carlo approach of dropping pixels and seeing if they’re inside or out of the area bounded by the two route lines… but not sure about that either.



Just thought might be the kind of thing someones looked at before?



Thanks!

What do you need the data for, when do you need it, how are you using it, etc?



That might help give some context for answering the question.

Well, I need the data as a metric of performance of different convoy communication implementations. If the deviation from the car they’re supposed to be following is high, then that’s not a good communication solution, and vice versa. The output is just a sum of areas, I.e. numerical… so I’d use that in analyzing benefits and drwabacks of different implementations.



Can be calculated in realtime or post analysis. At the moment I’m thinking of having a small Java app which can extract the logged possitions out of the database and analyse after the scenario.



Hope that helps clarify… recent paper of mine published http://www.ia.urjc.es/att2012/papers/att2012_submission_19.pdf

I assume you’re not concerned with comparing each route at certain increments of time or distance. Each route is bound to have different total times and distances traveled, so once one car is finished, you’ll have nothing to compare the other to…



That makes it a little more complicated since you need to find the shortest distance from each point along one line to any point on the next line, as opposed to just finding the distance between 2 known points at the same time or distance step along both routes.



Maybe you can still do that: given a point on Line A (following car), just iteratively check distances to points on Line B (lead car) until you have a minimum. Then switch to the next point on Line A. Sounds brutal, but maybe you can optimize it by using the closest point found from the previous comparison as a starting point, for example, and compare for a bit out in each direction from there. Assume a local minimum found here is the minimum.



Sum up those distances and you have your area.

Hmm, personally I’d probably dump all the data out to a database - you can then interpolate between data points to get the position at any time and do the analysis on this.

Sorry for digging this out :slight_smile: I am need the a deviation calculation for the same reason.
@vinnieb: Which way did you go?

And another question: in Terms of total deviation, wouldn’t it be the most precise solution, to draw a “face” from the two lines by connecting their interpolated points with triangles and get the total area from the triangles faces?

Well i’m not sure mine was the best, but it seems to work ok. i basically build up a long array of a lead vehicles positions. then, i have an array of the following vehicle positions, and for each position there, find the closest one of the leader. iterate though and sum up the differences.

I can get away with that, as the lead vehicle doesnt double back on itself, and I have a pretty fast sampling rate so lots of points to play with. Plus, a coarse answer is OK for me.

Am sure theres a much smarter way to do it, when you effectively have 2d bounded areas, but I didnt get much time to focus on it