Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/Beta/Geometry/Linear/Cube.cpp

Go to the documentation of this file.
00001 // Implementation of class JCube
00002 #ifndef __J2K__JCube_HPP__
00003 #define __J2K__JCube_HPP__
00004 
00005 #include <j2k/Fred/Geometry/JCube.hpp>
00006 
00007 JCube::JCube()
00008   : sq( 0.0, 0.0, 0.0 ), area_cache( 0.0 ), volume_cache( 0.0 ) { }
00009 
00010 JCube::JCube( double X )
00011   : sq( X, 0.0, 0.0 ), area_cache( 0.0 ), volume_cache( 0.0 ) { }
00012 
00013 JCube::JCube( double X, double Y )
00014   : sq( X, Y, 0.0 ), area_cache( 0.0 ), volume_cache( 0.0 ) { }
00015 
00016 JCube::JCube( double X, double Y, double Length )
00017   : sq( X, Y, Length ), area_cache( -1.0 ), volume_cache( -1.0 ) { }
00018 
00019 ////////////////////////////////////////////////////////////////////////////
00020 ///  JCube specific functions.                                           ///
00021 ////////////////////////////////////////////////////////////////////////////
00022 
00023 // Calculate surface area of Cube
00024 double JCube::area() const {   //  Area = 6 * square
00025   if ( area_cache < 0.0 ) {
00026     area_cache = 6 * sq.area();
00027   }
00028   return area_cache;
00029 }
00030 
00031 // Calculate volume of Cube
00032 double JCube::volume() const { // sq.length ^ 3
00033    if ( volume_cache < 0.0 ) {
00034      double l = sq.getLength();
00035      volume_cache = l * l * l;
00036    }
00037    return volume_cache;
00038 }
00039 
00040 ////////////////////////////////////////////////////////////////////////////
00041 ///  Square related functions.                                           ///
00042 ////////////////////////////////////////////////////////////////////////////
00043 
00044 // Set Length
00045 inline void JCube::setLength( double l ) {
00046   sq.setLength( l );
00047 }
00048 
00049 // Get Length
00050 inline double JCube::getLength() const {
00051   return sq.getLength();
00052 }
00053 
00054 ////////////////////////////////////////////////////////////////////////////
00055 ///  Point related functions.                                            ///
00056 ////////////////////////////////////////////////////////////////////////////
00057 
00058 // Set the x and y coordinates
00059 inline JCube&  JCube::setPoint( double X, double Y ) {
00060    sq.setPoint( X, Y );
00061    return *this;
00062 }
00063 
00064 // Set coordinates (r,t)
00065 inline JCube&  JCube::setPolar( double R, double Theta ) {
00066    sq.setPolar( R, Theta );
00067    return *this;
00068 }
00069 
00070 // Set the x and y coordinates
00071 inline JCube&  JCube::setSquare( double X, double Y, double Length )
00072 {
00073    sq.setSquare( X, Y, Length );
00074    return *this;
00075 }
00076 
00077 inline JCube&  JCube::setX( double X ) {
00078    sq.setX( X );
00079    return *this;
00080 }
00081 
00082 inline JCube&  JCube::setY( double Y ) {
00083    sq.setY( Y );
00084    return *this;
00085 }
00086 
00087 inline JCube&  JCube::setR( double R ) {
00088    sq.setR( R );
00089    return *this;
00090 }
00091 
00092 inline JCube&  JCube::setAngle( double Theta ) {
00093    sq.setAngle( Theta );
00094    return *this;
00095 }
00096 
00097 // get x coordinate
00098 inline double getX() const {
00099   return sq.getX();
00100 }
00101 
00102 // get y coordinate
00103 inline double getY() const {
00104   return sq.getY();
00105 }
00106 
00107 // get R coordinate
00108 inline double getR() const {
00109   return sq.getR();
00110 }
00111 
00112 // get Angle
00113 inline double getAngle() const {
00114   return sq.getAngle();
00115 }
00116 
00117 #endif

Generated on Sun Oct 14 18:46:07 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001