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

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