GEAR  1.9.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends Pages
BoundaryTrapezoid.cc
1 #include "gearsurf/BoundaryTrapezoid.h"
2 
3 #include "CLHEP/Vector/Rotation.h"
4 
5 namespace gear{
6 
7  bool BoundaryTrapezoid::isInBoundary( CLHEP::Hep3Vector local ) const {
8 
9  if( fabs( local.z() ) > _deltaW ) return false;
10 
11  // First we need to take into account, that the trapezoid might be rotated
12  // around w. So we transpose the local coordinates to the frame of the rectangle
13  // If the trapezoid is rotated by alpha, we need to rotate the coordinates by -alpha
14  CLHEP::HepRotation R;
15  R.rotateZ( -_alpha);
16  local = R * local; //to rectangle system
17 
18  if( fabs( local.y() ) > _height/2. ) return false;
19 
20  // Calculate the width of the trapezoid at the given height
21  double width = (_baseBottom + _baseTop)/2. + local.y() * (_baseTop - _baseBottom) / _height;
22  if( fabs( local.x() ) > width/2. ) return false;
23 
24 
25  return true;
26 
27  }
28 
29 }//end of gear namespace
virtual bool isInBoundary(CLHEP::Hep3Vector local) const