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/Rectangle.cpp

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

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