//*--- Author: Erik Krebs // from ROOT #include "TVector3.h" #include "hkalplane.h" #include #include using namespace std; ClassImp(HKalPlane) //_HADES_CLASS_DESCRIPTION /////////////////////////////////////////////////////////////////////////////// // // Class: HKalPlane // // A class that implements a planar surface of infinite dimension. The plane // is defined by a point on the plane and its normal vector which is a unit // vector. // //----------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////////////// // ----------------------------------- // Ctors and Dtor // ----------------------------------- HKalPlane::HKalPlane(const TVector3 ¢er, const TVector3 &normal) : TObject() { // Creates a plane defined by a point on the plane and its normal vector. // Hesse Normal Form: center * normal - d = 0 // center: a point on the plane. // normal: normal vector of the plane. vCenter = center; vNormal = normal.Unit(); } HKalPlane::~HKalPlane() { } // ----------------------------------- // Implementation of public methods // ----------------------------------- Double_t HKalPlane::distanceToPlane(const TVector3 &point) const { // Calculates the distance of vector pos to the plane. // Requires the normal vector of the plane to be a unit vector. Double_t d0 = getCenter() * getNormal(); // Distance d of plane to centre of coordinate system. // Plane equation in Hesse Normal Form: center * normal - d = 0 // Distance of point to plane = point * normal - d return TMath::Abs(point * getNormal() - d0); } Bool_t HKalPlane::findIntersection(TVector3 &pointIntersect, const TVector3 &pos, const TVector3 &dir) const { // Finds the intersection point of a straight line with this plane. // pointIntersect: the intersection point (will be modified). // pos: a point on the straight line. // dir: direction of the straight line. return findIntersection(pointIntersect, pos, dir, getCenter(), getNormal()); } Bool_t HKalPlane::findIntersection(TVector3 &pointIntersect, const TVector3 &pos, const TVector3 &dir, const TVector3 &planeCenter, const TVector3 &planeNormal) const { // Finds the intersection point of a straight line with any plane. // pointIntersect: the intersection point (will be modified). // pos: a point on the straight line. // dir: direction of the straight line. // planeCenter: a point on the plane. // planeNormal: normal vector of the plane. Double_t denom = planeNormal.Dot(dir); if (denom != 0.0) { Double_t t = ((planeCenter.x() - pos.x()) * planeNormal.x() + (planeCenter.y() - pos.y()) * planeNormal.y() + (planeCenter.z() - pos.z()) * planeNormal.z()) / denom; pointIntersect = pos + (t * dir); return kTRUE; } else { Warning("findIntersection()","No intersection point found : (plane || track)"); return kFALSE; } return kFALSE; } Bool_t HKalPlane::isOnSurface(const TVector3 &point) const { // Checks if point is on the plane. Double_t dist = distanceToPlane(point); return ((TMath::Abs(dist) < 1.e-10) ? kTRUE : kFALSE); } void HKalPlane::print(Option_t* opt) const { // Print center and normal vectors of this plane. // opt: print options (not used) cout<<"**** Properties of plane: ****"<