Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Trap.cxx

Go to the documentation of this file.
00001 //  $Id: Trap.cxx,v 1.1.1.1 1999/12/20 22:28:07 burnett Exp $
00002 //
00003 
00004 #include "geometry/Trap.h"
00005 
00006 static Vector N(const Vector& A, const Vector& B, const Vector& C)
00007 {
00008    // define a plane with vectors to three (non-colinear) Vectors
00009    Vector AB = A-B,
00010           AC = A-C,
00011                   n  = (AB.cross(AC)).unit();
00012    return (n*A) * n;
00013 }
00014 
00015 Trap::Trap( double h, double th,
00016             double w1, double bl1, double tl1, double th1,
00017             double w2, double bl2, double tl2 )
00018 : Hexahedron()
00019 {
00020 //  Make a Trap with the following 9 parameters:
00021 //       1) the full length in z (h)
00022 //       2) the polar angle of the center of the -z face to the center of
00023 //              the +z face (th) (-PI/2 < th < +PI/2)
00024 //       3) the full length in y of the -z face (w1)
00025 //       4) the full length in x of the low y edge of the -z face (bl1)
00026 //       5) the full length in x of the high y edge of the -z face (tl1)
00027 //       6) the angle with respect to the y-axis from the center of the
00028 //              low y edge to the center of the high y edge of the -z face
00029 //              (th1) (-PI/2 < th1 < +PI/2)
00030 //       7) the full length in y of the +z face (w2)
00031 //       8) the full length in x of the low y edge of the +z face (bl2)
00032 //       9) the full length in x of the high y edge of the +z face (tl2)
00033 //  The center of the Trap is at the origin of the global coordinate system
00034 //  and the axes are lined up with the global x (length), y (width), and
00035 //  z (height) axes
00036         if(   ( h <= 0.0 )
00037            || ( w1 <= 0.0 ) || ( bl1 <= 0.0 ) || ( tl1 <= 0.0 )
00038            || ( w2 <= 0.0 ) || ( bl2 <= 0.0 ) || ( tl2 <= 0.0 )
00039            || fabs( th ) >= 0.5 * M_PI
00040            || fabs( th1) >= 0.5 * M_PI
00041           )     FATAL("Illegal parameters for a Trap");
00042 
00043         double hh = 0.5 * h;
00044         double hw1 = 0.5 * w1;
00045         double hw2 = 0.5 * w2;
00046         double hbl1 = 0.5 * bl1;
00047         double hbl2 = 0.5 * bl2;
00048         double htl1 = 0.5 * tl1;
00049         double htl2 = 0.5 * tl2;
00050         double hw1t = hw1 * tan( th1 );
00051         double hht = hh * tan( th );
00052     //  Setup the vertices of the Trap
00053         Vector A (  hht + htl2 + hw1t,   hw2,  hh );
00054         Vector B (  hht - htl2 + hw1t,   hw2,  hh );
00055         Vector C (  hht + hbl2 - hw1t,  -hw2,  hh );
00056         Vector D (  hht - hbl2 - hw1t,  -hw2,  hh );
00057         Vector E ( -hht + htl1 + hw1t,   hw1, -hh );
00058         Vector F ( -hht - htl1 + hw1t,   hw1, -hh );
00059         Vector G ( -hht + hbl1 - hw1t,  -hw1, -hh );
00060         Vector H ( -hht - hbl1 - hw1t,  -hw1, -hh );
00061 //  Construct six planes
00062     addPlane(N(A,C,G));  //(+x)
00063         addPlane(N(D,B,H));      //(-x)
00064         addPlane(N(B,A,F));      //(+y)
00065         addPlane(N(C,D,G));      //(-y)
00066         addPlane(N(A,B,C));      //(+z)
00067         addPlane(N(F,E,H));      //(-z)
00068 }
00069 
00070         double Trap::height() const{return 0 ;}   // put these off for now, or until Bill complains
00071         double Trap::theta() const{return 0 ;}
00072         double Trap::width1() const{return 0 ;}
00073         double Trap::lengthLow1() const{return 0 ;}
00074         double Trap::lengthHigh1() const {return 0 ;}
00075         double Trap::theta1() const {return 0 ;}
00076         double Trap::width2() const {return 0 ;}
00077         double Trap::lengthLow2() const {return 0 ;}
00078         double Trap::lengthHigh2() const {return 0 ;}
00079 
00080 void Trap::printOn( std::ostream& os ) const
00081 {
00082      Volume::printOn(os);
00083          os
00084            << "height "       << height()
00085            << ", theta "      << theta()
00086            << "\nwidth_1 "    << width1()
00087            << ", length_low_1 " << lengthLow1()
00088            << ", length_high_1 " << lengthHigh1()
00089            << ", theta_1 "    << theta1()
00090            << "\nwidth_2 "    << width2()
00091            << ", length_low_2 " << lengthLow2()
00092            << ", length_high_2 " << lengthHigh2()
00093            << "\n" ;
00094 }
00095 
00096 

Generated at Mon Nov 26 18:18:21 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000