6

As you can see , I have a winform chart ( DevExpress Chart ) with two series . enter image description here
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 .

zey
  • 5,939
  • 14
  • 56
  • 110
  • Can you share the values of all points in your series and create [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve)? – nempoBu4 Apr 07 '17 at 05:58
  • For the series with red color { (4,A) (2,B) (10,C) (8,D) (6,E) (1,F)} For the series with blue color { (0.5,A) (9.8,B) (5.5,C) (5.3,D) (2.5,E) (4.5,F)} . – zey Apr 07 '17 at 06:11
  • But you can consider the argument (A,B,C,D,E,F) as number value (1,2,3,4,5,6) if you wish . For example For the series with red color { (4,1) (2,2) (10,3) (8,4) (6,5) (1,6)} For the series with blue color { (0.5,1) (9.8,2) (5.5,4) (5.3,4) (2.5,5) (4.5,6)} – zey Apr 07 '17 at 06:13
  • @zey are your points values randomly created or according to some type of mathematical function? – jambonick Apr 10 '17 at 09:17
  • @zey as the c++ implementation requires CGAL functions maybe this link can help you http://stackoverflow.com/questions/4213117/the-generalization-of-bentley-ottmann-algorithm – jambonick Apr 12 '17 at 12:38

2 Answers2

5

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.

DonBoitnott
  • 10,787
  • 6
  • 49
  • 68
0

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)

Alex Aparin
  • 4,393
  • 5
  • 25
  • 51