Geometry points

Hi,
I’m using the geometry classes but I’m stuck on a problem.

Is there a way to get the main points of a geometry ?

For example :
I produce this geometry by cutting cylinders using TGeoIntersection. For the red TGeoCompositeShape, I have to get the A,B points, the center (ok for this) and a point on the arc.

Is this possible ?

TSD.

image Cutted cylinder

Yes, you can use the DistanceToIn/Out interface of TGeoShape. For example, if you know the coordinates of a point on the AB line and the direction of AB vector, you can call DistanceToIn/Out for the component cylinders after converting the point to their local coordinates. Think of this method as using a “ruler”. It may be tricky to find your reference points, but TGeoCompositeShape cannot offer this kind of functionality due to the complexity and infinite number of shape combinations.

Hi,
I tried this, it works fine in a lot of cases, but I found unexpected results with a TGeoPgon.

I launched DistanceFromOutside with the (0;0;0) starting point and the (0;1;0) vector to find the first intersection. But it returns 80.0 instead of 40.0 on the Y axis. I changed the size values of the tube but no changes.
I found a solution to this problem by moving the starting point to (0;0.00001;0).
Did I miss something ?

The DistanceFromInside seems work well and returns 50, the good value. These methods are working well with a cylindrical tube.

Illustration :
image

Hi, for the Pgon you may have hit a singularity where the algorithm behaves bad. To fix the bug, I would need the shape (preferrably saved in a ROOT file) and starting point/direction.

Here is my script, and shape.

Starting point : 0;0;0
Direction : 0;1;0
You can find these values in the python file.

You can try to set the starting point to 0;0.00001;0. It works fine with values near 0 but not with 0.

shape.root (1.7 KB)
TGeoPgon_DistanceFromOutside_BUG.py (2.0 KB)

Hi, I converted your python script to a C macro trying to debug, but I get correct result with the master:

inside_y >>>>>>> 50 #Expected : 50.0#
outside_y >>>>>> 40 #Expected : 40.0#

Note that the call for DistanceFromInside from (0,0,0) gives a “correct” answer just by chance since a point inside the “hole” of the Pgon shape is not considered inside the shape, so you are supposed to call only DistanceFromOutside

Note that when you use distance methods as a “ruler”, you should avoid querying along side planes, which may give unpredictible results.

bug.C (2.2 KB)