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.hpp

Go to the documentation of this file.
00001 // Definition of class JRectangle
00002 #ifndef __J2K__JRectangle_HPP__
00003 #define __J2K__JRectangle_HPP__
00004 
00005 // Member function definitions for class JRectangle
00006 #include <j2k/Fred/StdTypes.hpp>
00007 #include <j2k/Fred/Basic.hpp>
00008 #include <j2k/Fred/Geometry/Point.hpp>
00009 
00010 class JRectangle {
00011 public:
00012    JRectangle()                                    // Default Constructor
00013    JRectangle( double X );                         // Constructor ( x, 0 )
00014    JRectangle( double X, double Y );               // Constructor ( x, y )
00015 
00016    JRectangle( double X, double Y,
00017               double Length );           // Assume it's JSquare
00018 
00019    JRectangle( double X, double Y,                 
00020               double Length, double Width );
00021 
00022    double  getLength() const;          // get Length
00023    double  getWidth()  const;          // get Width
00024 
00025             double  area() const;               // Calculate area
00026 
00027    inline JRectangle& setJSquare( double X, double Y, double Length );
00028 
00029    inline JRectangle& setJRectangle( double X, double Y,
00030                      double Length, double Width );
00031 
00032    inline JRectangle& setLength( double Length ); // set Length
00033    inline JRectangle& setWidth(  double Width  ); // set Width
00034 
00035    // Output a JRectangle in the form:
00036    // Center = [x, y]; Length = #.##
00037    friend ostream&  operator<<( ostream &output, const JRectangle &rec )
00038    {
00039      output << "Position = " << rec.p
00040             << "; Length = " 
00041             << setiosflags( ios::fixed | ios::showpoint )
00042             << setprecision( 2 ) << rec.length;
00043             << "; Width = " 
00044             << setiosflags( ios::fixed | ios::showpoint )
00045             << setprecision( 2 ) << rec.width;
00046      return output;                              //  enables cascaded calls
00047    }
00048 
00049    // Same as Point
00050    inline JRectangle& setPoint( double X, double Y );   // Set coordinates (x,y)
00051    inline JRectangle& setPolar( double X, double Y );   // Set coordinates (r,t)
00052 
00053    inline JRectangle& setX( double X );                 // Set x coordinate
00054    inline JRectangle& setY( double Y );                 // Set y coordinate
00055    inline JRectangle& setR( double R );                 // Set r coordinate
00056    inline JRectangle& setAngle( double Theta );         // Set angle
00057 
00058    inline double getX() const;                      // get x coordinate
00059    inline double getY() const;                      // get y coordinate
00060    inline double getR() const;                      // get r coordinate
00061    inline double getAngle() const;                  // get angle
00062 
00063 protected:                               // accessible to derived classes
00064    Point& p;                             // Point to center of JRectangle
00065    double length;               // Length of the JRectangle
00066    double width;                // Width  of the JRectangle
00067    double area_cache;                    // Cached Area is valid, if > 0
00068 };
00069 
00070 #endif
00071 
00072 

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