]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliStrLine.cxx
New constructor from the coordinates of two points (Massimo)
[u/mrichter/AliRoot.git] / STEER / AliStrLine.cxx
index 5a6ab1d65d4310d4f708d8063b8796ed1c946ad2..5f57fd56e8f799fca4be901165ef612cac07f45a 100644 (file)
@@ -36,8 +36,25 @@ AliStrLine::AliStrLine() {
 }
 
 //________________________________________________________
-AliStrLine::AliStrLine(Double_t *point, Double_t *cd) {
+AliStrLine::AliStrLine(Double_t *point, Double_t *cd,Bool_t twopoints) {
   // Standard constructor
+  // if twopoints is true:  point and cd are the 3D coordinates of
+  //                        two points defininig the straight line
+  // if twopoint is false: point represents the 3D coordinates of a point
+  //                       belonging to the straight line and cd is the
+  //                       direction in space
+  if(twopoints){
+    InitTwoPoints(point,cd);
+  }
+  else {
+    InitDirection(point,cd);
+  }
+}
+
+
+//________________________________________________________
+void AliStrLine::InitDirection(Double_t *point, Double_t *cd){
+  // Initialization from a point and a direction
   Double_t norm = 0.;
   for(Int_t i=0;i<3;i++)norm+=cd[i]*cd[i];
   if(norm) {
@@ -53,6 +70,15 @@ AliStrLine::AliStrLine(Double_t *point, Double_t *cd) {
   SetDebug();
 }
 
+//________________________________________________________
+void AliStrLine::InitTwoPoints(Double_t *pA, Double_t *pB){
+  // Initialization from the coordinates of two
+  // points in the space
+  Double_t cd[3];
+  for(Int_t i=0;i<3;i++)cd[i] = pB[i]-pA[i];
+  InitDirection(pA,cd);
+}
+
 //________________________________________________________
 AliStrLine::~AliStrLine() {
   // destructor