ROOT logo
// @(#)root/g3d:$Id: THelix.h 21901 2008-01-29 10:22:44Z couet $
// Author: Ping Yeh   19/12/97

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_THelix
#define ROOT_THelix


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// THelix                                                               //
//                                                                      //
// A Helix with axis // z-axis:                                         //
//                                                                      //
//  X(t) = X0 - vt / w sin(-wt+phi0)                                    //
//  Y(t) = Y0 + vt / w cos(-wt+phi0)                                    //
//  Z(t) = Z0 + vz t                                                    //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TPolyLine3D
#include "TPolyLine3D.h"
#endif
#ifndef ROOT_TRotMatrix
#include "TRotMatrix.h"
#endif

enum EHelixRangeType {
   kHelixT, kHelixX, kHelixY, kHelixZ, kLabX, kLabY, kLabZ, kUnchanged
};


class THelix : public TPolyLine3D {

protected:
   Double_t     fX0;       //Pivot's x position (see parametrization in class doc)
   Double_t     fY0;       //Pivot's y position (see parametrization in class doc)
   Double_t     fZ0;       //Pivot's z position (see parametrization in class doc)
   Double_t     fVt;       //Transverse velocity (constant of motion)
   Double_t     fPhi0;     //Initial phase, so vx0 = fVt*cos(fPhi0)
   Double_t     fVz;       //Z velocity (constant of motion)
   Double_t     fW;        //Angular frequency
   Double_t     fAxis[3];  //Direction unit vector of the helix axis
   TRotMatrix  *fRotMat;   //Rotation matrix: axis // z  -->  axis // fAxis
   Double_t     fRange[2]; //Range of helix parameter t

   THelix& operator=(const THelix&);

   void         SetRotMatrix();    //Set rotation matrix
   Double_t     FindClosestPhase(Double_t phi0,  Double_t cosine);

   static Int_t fgMinNSeg;   //minimal number of segments in polyline

public:
   THelix();
   THelix(Double_t x,  Double_t y,  Double_t z,
          Double_t vx, Double_t vy, Double_t vz,
          Double_t w);
   THelix(Double_t * xyz, Double_t * v, Double_t w,
          Double_t * range=0, EHelixRangeType rtype=kHelixZ,
          Double_t * axis=0);
   THelix(const THelix &helix);
   virtual ~THelix();

   virtual void    Copy(TObject &helix) const;
   virtual void    Draw(Option_t *option="");
   Option_t       *GetOption() const {return fOption.Data();}
   virtual void    Print(Option_t *option="") const;
   virtual void    SavePrimitive(ostream &out, Option_t *option = "");
   virtual void    SetOption(Option_t *option="") {fOption = option;}
   virtual void    SetAxis(Double_t * axis);       //Define new axis
   virtual void    SetAxis(Double_t x, Double_t y, Double_t z);
   virtual void    SetRange(Double_t * range, EHelixRangeType rtype=kHelixZ);
   virtual void    SetRange(Double_t r1, Double_t r2, EHelixRangeType rtype=kHelixZ);
   void            SetHelix(Double_t *xyz,  Double_t *v, Double_t w,
                            Double_t *range=0, EHelixRangeType type=kUnchanged,
                            Double_t *axis=0);

   ClassDef(THelix,2)  //A Helix drawn as a PolyLine3D
};

#endif
 THelix.h:1
 THelix.h:2
 THelix.h:3
 THelix.h:4
 THelix.h:5
 THelix.h:6
 THelix.h:7
 THelix.h:8
 THelix.h:9
 THelix.h:10
 THelix.h:11
 THelix.h:12
 THelix.h:13
 THelix.h:14
 THelix.h:15
 THelix.h:16
 THelix.h:17
 THelix.h:18
 THelix.h:19
 THelix.h:20
 THelix.h:21
 THelix.h:22
 THelix.h:23
 THelix.h:24
 THelix.h:25
 THelix.h:26
 THelix.h:27
 THelix.h:28
 THelix.h:29
 THelix.h:30
 THelix.h:31
 THelix.h:32
 THelix.h:33
 THelix.h:34
 THelix.h:35
 THelix.h:36
 THelix.h:37
 THelix.h:38
 THelix.h:39
 THelix.h:40
 THelix.h:41
 THelix.h:42
 THelix.h:43
 THelix.h:44
 THelix.h:45
 THelix.h:46
 THelix.h:47
 THelix.h:48
 THelix.h:49
 THelix.h:50
 THelix.h:51
 THelix.h:52
 THelix.h:53
 THelix.h:54
 THelix.h:55
 THelix.h:56
 THelix.h:57
 THelix.h:58
 THelix.h:59
 THelix.h:60
 THelix.h:61
 THelix.h:62
 THelix.h:63
 THelix.h:64
 THelix.h:65
 THelix.h:66
 THelix.h:67
 THelix.h:68
 THelix.h:69
 THelix.h:70
 THelix.h:71
 THelix.h:72
 THelix.h:73
 THelix.h:74
 THelix.h:75
 THelix.h:76
 THelix.h:77
 THelix.h:78
 THelix.h:79
 THelix.h:80
 THelix.h:81
 THelix.h:82
 THelix.h:83
 THelix.h:84
 THelix.h:85
 THelix.h:86
 THelix.h:87
 THelix.h:88
 THelix.h:89