Milo  0.1
Milo:EquationManipulationProgram
Private Types | Private Attributes | List of all members
Rectangle< T > Class Template Reference

#include <util.h>

Public Member Functions

Constructors
 Rectangle ()
 
 Rectangle (T x, T y, T x0, T y0)
 
Mutators
void set (T x, T y, T x0, T y0)
 
void setOrigin (T x0, T y0)
 
void setSize (T x, T y)
 
Accessors
int & x0 ()
 
int & y0 ()
 
int & width ()
 
int & height ()
 
int x0 () const
 
int y0 () const
 
int width () const
 
int height () const
 

Private Types

enum  {
  WIDTH, HEIGHT, X0, Y0,
  SIZE
}
 

Private Attributes

std::array< T, SIZE > m_rect
 Storage of rectangle parameters.
 

Helper Member Functions

std::string toString ()
 
T area ()
 
bool inside (T x, T y) const
 
bool inside (Rectangle r) const
 
bool intersect (const Rectangle &r) const
 
void merge (const Rectangle &r)
 
static Rectangle merge (const Rectangle &r1, const Rectangle &r2)
 

Detailed Description

template<class T>
class Rectangle< T >

Rectangle template class. Holds a rectange as an origin and a width and height, plus helper member functions. Template type can be any numerical type.

Constructor & Destructor Documentation

template<class T>
Rectangle< T >::Rectangle ( )
inline

Default constructor for Rectangle. Set origin and dimensions to zero.

template<class T>
Rectangle< T >::Rectangle ( T  x,
T  y,
T  x0,
T  y0 
)
inline

Constructor for Rectangle from all 4 coordinates.

Parameters
xWidth of rectangle.
yHeight of rectangle.
x0Horizontal origin of rectangle.
y0Vertical origin of rectangle.

Member Function Documentation

template<class T>
T Rectangle< T >::area ( )
inline

Return area of rectangle.

Returns
Area of rectangle.
template<class T>
int& Rectangle< T >::height ( )
inline

Get reference to Rectangle's height.

Returns
Reference to Rectangle's height.
template<class T>
int Rectangle< T >::height ( ) const
inline

Get Rectangle's height

Returns
Rectangle's height
template<class T>
bool Rectangle< T >::inside ( T  x,
T  y 
) const
inline

Check if point is inside Rectangle.

Parameters
xHorizontal origin of point.
yVertical origin of point.
Returns
Return true if point (x,y) is inside Rectangle.
template<class T>
bool Rectangle< T >::inside ( Rectangle< T >  r) const
inline

Check if this rectangle is inside given Rectangle r.

Parameters
rRectangle to be tested
Returns
Return true if this rectangle is inside r.
template<class T>
bool Rectangle< T >::intersect ( const Rectangle< T > &  r) const
inline

Detect overlap between this rectangle and another.

Returns
True if rectangle r intersects with rectangle in class object.
template<class T>
void Rectangle< T >::merge ( const Rectangle< T > &  r)
inline

Merge rectangle in class object with rectangle r

template<class T>
static Rectangle Rectangle< T >::merge ( const Rectangle< T > &  r1,
const Rectangle< T > &  r2 
)
inlinestatic

return rectangle that is merger of r1 and r2

template<class T>
void Rectangle< T >::set ( T  x,
T  y,
T  x0,
T  y0 
)
inline

Set origin and dimension of Rectangle.

Parameters
xWidth of rectangle.
yHeight of rectangle.
x0Horizontal origin of rectangle.
y0Vertical origin of rectangle.
template<class T>
void Rectangle< T >::setOrigin ( T  x0,
T  y0 
)
inline

Set origin of Rectangle.

Parameters
x0Horizontal origin of rectangle.
y0Vertical origin of rectangle.
template<class T>
void Rectangle< T >::setSize ( T  x,
T  y 
)
inline

Set dimension of Rectangle.

Parameters
xWidth of rectangle.
yHeight of rectangle.
template<class T>
std::string Rectangle< T >::toString ( )
inline

Convert state of this class to string

Returns
Return string representing this object
template<class T>
int& Rectangle< T >::width ( )
inline

Get reference to Rectangle's width.

Returns
Reference to Rectangle's width.
template<class T>
int Rectangle< T >::width ( ) const
inline

Get Rectangle's width

Returns
Rectangle's width
template<class T>
int& Rectangle< T >::x0 ( )
inline

reference to Rectangle's horizontal origin.

Returns
Reference to Rectangle's horizontal origin.
template<class T>
int Rectangle< T >::x0 ( ) const
inline

Get Rectangle's horizontal origin

Returns
Rectangle's horizontal origin
template<class T>
int& Rectangle< T >::y0 ( )
inline

Get reference to Rectangle's vertical origin.

Returns
Reference to Rectangle's vertical origin.
template<class T>
int Rectangle< T >::y0 ( ) const
inline

Get Rectangle's vertical origin

Returns
Rectangle's vertical origin

The documentation for this class was generated from the following file: