A TGraph line intersection method

Dear ROOTers,

I have a possible addition to the TGraph class. I needed a method to estimate where a line intersected another line or a TCutG region. Assuming these lines are straight lines between points, the added methods [GetIntersections(TGraph &b) and GetIntersections(TCutG &b)] find all the intersections and return them as a TGraph object. It is then up to the user to extract the points from this instance if they want the values (I have attached an example in linetest.C).

I don’t know if this method is redundant, I haven’t found anything like it in ROOT, but I would gladly “donate” it for inclusion in any case :slight_smile:

Cheers,

Morten


linetest.C (3.57 KB)
TGraph.cxx (81.4 KB)
TGraph.h (9.54 KB)

Hello,

I looked at your code. It looks good and does the job. But I think it could stay as an external procedure in a macro. There is no real need to put it as on of the TGraph’s methods. You can also make your “own TGraph” inheriting from TGraph. Up to you.

Cheers,
Olivier