Hi Kevin,
Indeed, you can easily do that with the TGeo classes. A simple macro
just to do what you want :
{
gSystem->Load("libGeom");
new TGeoManager("geom", "testing shapes"); // you must have a manager
// now the global gGeoManager points to it
//-> just make a sphere (TGeoSphere), without having in fact a
// geometry :
TGeoShape *shape = new TGeoSphere(10, 20); // Rmin, Rmax
Double_t point[3];
Double_t dir[3];
// ... define your point and direction components here.
Bool_t inside = shape->Contains(point);
Double_t dist;
if (inside) dist = shape->DistToOut(point,dir,3);
else dist = shape->DistToIn(point,dir,3);
// if you get dist<1E30, your ray have crossed the sphere
cout << "whatever" << endl;
delete gGeoManager; // this will clean everything
}
You can test with any other shape.
Note that if you want to find where you are or compute distances when
many shapes are involved, you actually have to build-up a geometry. In
this case you will not have to test directly shapes any more.
Regards,
Andrei
Kevin Reil wrote:
> Hi all,
>
> Answering my own question perhaps but the class TGeoShape seems to have
> within it everything I want. Does, for example, TSPHERE have a TGeoShape
> associated with it?
>
> Cheers,
> Kevin
>
> |------------------------------------|---------------------------------|
> | Kevin Reil | 2575 Sand Hill Road, MS 26 |
> | X2447, 103D A&E Bldg. 041 | Menlo Park, CA 94025 |
> |------------------------------------|---------------------------------|
> | http://www.slac.stanford.edu/~reil | Office (650) 926-2447 |
> | reil@slac.stanford.edu | Home (650) 938-1767 |
> | http://reil.no-ip.org | Fax (650) 926-5368 |
> |----------------------------------------------------------------------|
> | And my father dwelt in a tent. |
> |----------------------------------------------------------------------|
>
> On Tue, 27 May 2003, Kevin Reil wrote:
>
>
>>Hi rooters,
>>
>>I wish to find out of a point is contained within (or on the surface of)
>>a 3D object. (More accurately I wish to know if a line intersects an
>>object ie a raytrace).
>>
>>Is there such a feedback mechanism in the 3D geometry classes? For a TBRIK
>>its pretty easy, but TTUBE, TCONE etc it becomes much harder.
>>
>>Thanks,
>>Kevin
>>
>>|------------------------------------|---------------------------------|
>>| Kevin Reil | 2575 Sand Hill Road, MS 26 |
>>| X2447, 103D A&E Bldg. 041 | Menlo Park, CA 94025 |
>>|------------------------------------|---------------------------------|
>>| http://www.slac.stanford.edu/~reil | Office (650) 926-2447 |
>>| reil@slac.stanford.edu | Home (650) 938-1767 |
>>| http://reil.no-ip.org | Fax (650) 926-5368 |
>>|----------------------------------------------------------------------|
>>| And my father dwelt in a tent. |
>>|----------------------------------------------------------------------|
>>
>>On Tue, 27 May 2003, cstrato wrote:
>>
>>
>>>Dear Fons and Stanislav
>>>
>>>Thank you for this great solution. It really solves my special case.
>>>
>>>(In the case of *.txt, the only problem would be that normal users
>>>would be confused to see a grep expression instead of what they
>>>usually expect. But for the moment it does not matter.)
>>>
>>>Best regards
>>>Christian
>>>
>>>Fons Rademakers wrote:
>>>
>>>
>>>>Hi Stanislav,
>>>>
>>>>thanks for these remarks. In the GUI the following works and solves
>>>>Christian's problem:
>>>>
>>>>const char *filetypes[] = { "All files", "*",
>>>> "Text files", "*.[tT][xX][tT]",
>>>> 0, 0 };
>>>>
>>>>Cheers, Fons.
>>>>
>>>>
>>>>
>>>>On Mon, 2003-05-26 at 22:45, Stanislav Nesterov wrote:
>>>>
>>>>
>>>>
>>>>> Hi,
>>>>> I just want to clarify one point:
>>>>>expression "*.{txt,TXT}" in fact is not regexp at all but shell wildcard.
>>>>>
>>>>> To be more precise similar condition can be achieved via regex:
>>>>> .*\.(txt|TXT)
>>>>>or even
>>>>> .*\.[tT][xX][tT]
>>>>>
>>>>> Best regards,
>>>>> Stanislav.
>>>>>
>>>>>On 26 May 2003, Fons Rademakers wrote:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>Hi Christian,
>>>>>>
>>>>>>this is currently not supported via our regexp processor. Ideally this
>>>>>>should work "*.{txt,TXT}" but currently it doesn't.
>>>>>>
>>>>>>Cheers, Fons.
>>>>>>
>>>>>>
>>>>>>
>>>>>>On Sun, 2003-05-25 at 19:13, cstrato wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>>Dear Rooters
>>>>>>>
>>>>>>>TGFileDialog offers the possibility to show only files
>>>>>>>of selected type TGFileInfo::fFileTypes.
>>>>>>>
>>>>>>>However, I would like to display e.g. text-files only,
>>>>>>>which could have the extension *.txt or *.TXT.
>>>>>>>Is this possible, and how can I achieve this?
>>>>>>>
>>>>>>>Thank you in advance.
>>>>>>>Best regards
>>>>>>>Christian
>>>>>>>_._._._._._._._._._._._._._._._
>>>>>>>C.h.i.s.t.i.a.n S.t.r.a.t.o.w.a
>>>>>>>V.i.e.n.n.a A.u.s.t.r.i.a
>>>>>>>_._._._._._._._._._._._._._._._
>>>>>>>
>>>>>>>
>>>>>>
>>>
>>>
>
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:11 MET