00001
00002
00003
00004
00005
00006
00007 #include "geometry/Box.h"
00008
00009 static Vector _xhat(1,0,0), _yhat(0,1,0), _zhat(0,0,1);
00010
00011 Box::Box( double length, double width, double height ) : Hexahedron()
00012 {
00013
00014
00015
00016 constructSurfaces( length, width, height);
00017 }
00018
00019 void Box::resize( double length, double width, double height )
00020 {
00021
00022
00023
00024 deleteSurfaces();
00025 constructSurfaces( length, width, height);
00026 }
00027
00028 void Box::constructSurfaces( double length, double width, double height )
00029 {
00030
00031
00032 max_dimension = 0.5*sqrt( length*length + width*width + height*height);
00033
00034
00035
00036 addPlane( 0.5*length*_xhat );
00037 addPlane( -0.5*length*_xhat );
00038 addPlane( 0.5*width *_yhat );
00039 addPlane( -0.5*width *_yhat );
00040 addPlane( 0.5*height*_zhat );
00041 addPlane( -0.5*height*_zhat );
00042 }
00043
00044 double Box::length()const { return 2*plane(0).offset(); }
00045 double Box::width() const { return 2*plane(2).offset();}
00046 double Box::height()const { return 2*plane(4).offset(); }
00047
00048 const Vector& Box::xhat()const{ return plane(0).direction();}
00049 const Vector& Box::yhat()const{ return plane(2).direction();}
00050 const Vector& Box::zhat()const{ return plane(4).direction();}
00051