//_____________________________________________________________________________ // TG3Plane: class representing 2D plane in 3D space // Feb 03 2001 P.Murat //_____________________________________________________________________________ #include "TMath.h" #include "TG3Plane.hh" #include "TLine3D.hh" ClassImp(TG3Plane) //_____________________________________________________________________________ TG3Plane::TG3Plane() { } //_____________________________________________________________________________ TG3Plane::TG3Plane(const TVector3& R0, const TVector3& Normal) { fR0 = R0; fNormal = Normal.Unit(); } //_____________________________________________________________________________ TG3Plane::~TG3Plane() { } //_____________________________________________________________________________ Int_t TG3Plane::FindIntersection(const TLine3D& Line, TVector3& Point) { // returns 3D `Point' of intersection between the `Line' and *this plane int rc; TVector3 pos; TVector3 dir; Line.GetPosition(pos); Line.GetDirection(dir); Double_t denom = dir.Dot(fNormal); if (TMath::Abs(denom) > 1.e-10) { Double_t t = (fR0-pos).Dot(fNormal)/denom; Point.SetXYZ(pos.X()+t*dir.X(), pos.Y()+t*dir.Y(), pos.Z()+t*dir.Z()); rc = 0; } else { Point.SetXYZ(0.,0.,0.); rc = -1; } return rc; }