00001
00002
00003
00004 #include "geometry/Trap.h"
00005
00006 static Vector N(const Vector& A, const Vector& B, const Vector& C)
00007 {
00008
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
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
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
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
00062 addPlane(N(A,C,G));
00063 addPlane(N(D,B,H));
00064 addPlane(N(B,A,F));
00065 addPlane(N(C,D,G));
00066 addPlane(N(A,B,C));
00067 addPlane(N(F,E,H));
00068 }
00069
00070 double Trap::height() const{return 0 ;}
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