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

Box.cxx

Go to the documentation of this file.
00001 // $Id: Box.cxx,v 1.1.1.1 1999/12/20 22:28:06 burnett Exp $
00002 //
00003 //
00004 // Implement a box: this is it, folks!
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 //  Make a Box with dimensions length along the x-axis, width along the y-axis, and
00014 //  height along the z-axis.
00015 
00016     constructSurfaces( length, width, height);
00017 }
00018 
00019 void Box::resize( double length, double width, double height )
00020 {
00021 //  Resize this Box with dimensions length along the x-axis, width along the y-axis, and
00022 //  height along the z-axis.
00023 
00024     deleteSurfaces();
00025     constructSurfaces( length, width, height);
00026 }
00027 
00028 void Box::constructSurfaces( double length, double width, double height )
00029 {
00030 //  Make 6 planes to describe the box
00031 
00032    max_dimension = 0.5*sqrt( length*length + width*width + height*height);
00033 
00034 // Create and add surfaces: all with respect to Box's center
00035 // Note that order above counts here!
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 

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