Reputation: 6103
As you can see , I have a winform chart ( DevExpress Chart ) with two series .
Each series has their points.
And what I want is to find the overlapping points of those two series ( pointed by green circle in picture ) .
For example ( 3.4 for the first overlapping point and 7.3 for the second overlapping point ) .
Thanks .
Upvotes: 6
Views: 965
Reputation: 4522
As I understood each series in your case is just collection of sequantial points. All you need is to find intersection between line segments from each collection. I suggest to use for such purpose Bentley-Ottmann algorithm, which allows to find answer in (N log N) way (N is count of line segments from both series). Unfortunately I don't know whether there is implementation in c# (anytime you can use c++ implementation, if you will not find c# solution)
If you have always two series, defined by some two different functions, you can optimize algorithm in O (N) way (use "merge" logic)
Upvotes: 0
Reputation: 11035
If you have direct access to the Series
collection, you could:
var intersection = Series[0].Points.Intersect(Series[1].Points);
If you are creating discrete Point
objects along the way, you may have to define the matching behavior, as well.
Upvotes: 5