// @(#)root/g3d:$Id$
// Author: Nenad Buncic   19/09/95

/*************************************************************************
 * 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.             *
 *************************************************************************/

#include "TPARA.h"
#include "TNode.h"
#include "TMath.h"

ClassImp(TPARA)


//______________________________________________________________________________
// Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/para.gif"> </P> End_Html
// PARA is a parallelepiped. It has 9 parameters:
//
//     - name       name of the shape
//     - title      shape's title
//     - material  (see TMaterial)
//     - dx         half-length in x
//     - dy         half-length in y
//     - dz         half-length in z
//     - alpha      angle formed by the y axis and by the plane joining the
//                  centre of the faces parallel to the z-x plane at -DY and +DY
//     - theta      polar angle of the line joining the centres of the faces
//                  at -DZ and +DZ in z
//     - phi        azimuthal angle of the line joining the centres of the
//                  faces at -DZ and +DZ in z


//______________________________________________________________________________
TPARA::TPARA()
{
   // PARA shape default constructor

   fAlpha = 0.;
   fTheta = 0.;
   fPhi   = 0.;
}


//______________________________________________________________________________
TPARA::TPARA(const char *name, const char *title, const char *material, Float_t dx, Float_t dy, Float_t dz,
             Float_t alpha, Float_t theta, Float_t phi) : TBRIK(name, title,material, dx, dy, dz)
{
   // PARA shape normal constructor

   fAlpha = alpha;
   fTheta = theta;
   fPhi   = phi;
}


//______________________________________________________________________________
TPARA::~TPARA()
{
   // PARA shape default destructor
}


//______________________________________________________________________________
void TPARA::SetPoints(Double_t *points) const
{
   // Create PARA points

   if (!points) return;
   Float_t dx, dy, dz, theta, phi, alpha;
   const Float_t pi = Float_t (TMath::Pi());

   alpha = fAlpha * pi/180.0;
   theta = fTheta * pi/180.0;
   phi   = fPhi   * pi/180.0;

   dx = TBRIK::fDx;
   dy = TBRIK::fDy;
   dz = TBRIK::fDz;

   // Parallelepiped change angles to tangents (by Pavel Nevski 12/04/99)
   Double_t txy = TMath::Tan(alpha);
   Double_t tth = TMath::Tan(theta);
   Double_t txz = tth*TMath::Cos(phi);
   Double_t tyz = tth*TMath::Sin(phi);

   *points++ = -dz*txz-txy*dy-dx ; *points++ = -dy-dz*tyz ; *points++ = -dz;
   *points++ = -dz*txz+txy*dy-dx ; *points++ = +dy-dz*tyz ; *points++ = -dz; //3
   *points++ = -dz*txz+txy*dy+dx ; *points++ = +dy-dz*tyz ; *points++ = -dz;
   *points++ = -dz*txz-txy*dy+dx ; *points++ = -dy-dz*tyz ; *points++ = -dz;//1
   *points++ = +dz*txz-txy*dy-dx ; *points++ = -dy+dz*tyz ; *points++ = +dz;
   *points++ = +dz*txz+txy*dy-dx ; *points++ = +dy+dz*tyz ; *points++ = +dz;//7
   *points++ = +dz*txz+txy*dy+dx ; *points++ = +dy+dz*tyz ; *points++ = +dz;
   *points++ = +dz*txz-txy*dy+dx ; *points++ = -dy+dz*tyz ; *points++ = +dz;//5
}
 TPARA.cxx:1
 TPARA.cxx:2
 TPARA.cxx:3
 TPARA.cxx:4
 TPARA.cxx:5
 TPARA.cxx:6
 TPARA.cxx:7
 TPARA.cxx:8
 TPARA.cxx:9
 TPARA.cxx:10
 TPARA.cxx:11
 TPARA.cxx:12
 TPARA.cxx:13
 TPARA.cxx:14
 TPARA.cxx:15
 TPARA.cxx:16
 TPARA.cxx:17
 TPARA.cxx:18
 TPARA.cxx:19
 TPARA.cxx:20
 TPARA.cxx:21
 TPARA.cxx:22
 TPARA.cxx:23
 TPARA.cxx:24
 TPARA.cxx:25
 TPARA.cxx:26
 TPARA.cxx:27
 TPARA.cxx:28
 TPARA.cxx:29
 TPARA.cxx:30
 TPARA.cxx:31
 TPARA.cxx:32
 TPARA.cxx:33
 TPARA.cxx:34
 TPARA.cxx:35
 TPARA.cxx:36
 TPARA.cxx:37
 TPARA.cxx:38
 TPARA.cxx:39
 TPARA.cxx:40
 TPARA.cxx:41
 TPARA.cxx:42
 TPARA.cxx:43
 TPARA.cxx:44
 TPARA.cxx:45
 TPARA.cxx:46
 TPARA.cxx:47
 TPARA.cxx:48
 TPARA.cxx:49
 TPARA.cxx:50
 TPARA.cxx:51
 TPARA.cxx:52
 TPARA.cxx:53
 TPARA.cxx:54
 TPARA.cxx:55
 TPARA.cxx:56
 TPARA.cxx:57
 TPARA.cxx:58
 TPARA.cxx:59
 TPARA.cxx:60
 TPARA.cxx:61
 TPARA.cxx:62
 TPARA.cxx:63
 TPARA.cxx:64
 TPARA.cxx:65
 TPARA.cxx:66
 TPARA.cxx:67
 TPARA.cxx:68
 TPARA.cxx:69
 TPARA.cxx:70
 TPARA.cxx:71
 TPARA.cxx:72
 TPARA.cxx:73
 TPARA.cxx:74
 TPARA.cxx:75
 TPARA.cxx:76
 TPARA.cxx:77
 TPARA.cxx:78
 TPARA.cxx:79
 TPARA.cxx:80
 TPARA.cxx:81
 TPARA.cxx:82
 TPARA.cxx:83
 TPARA.cxx:84
 TPARA.cxx:85
 TPARA.cxx:86
 TPARA.cxx:87
 TPARA.cxx:88
 TPARA.cxx:89
 TPARA.cxx:90
 TPARA.cxx:91
 TPARA.cxx:92
 TPARA.cxx:93
 TPARA.cxx:94
 TPARA.cxx:95
 TPARA.cxx:96
 TPARA.cxx:97
 TPARA.cxx:98