58 lines
1.0 KiB
C++
58 lines
1.0 KiB
C++
//------------------------------------------------------------------------------
|
|
// Author: Gero Mueller <gero.mueller@cloo.de>
|
|
// Copyright: (c) 2006 Gero Mueller
|
|
// License: MIT License
|
|
//------------------------------------------------------------------------------
|
|
|
|
#ifndef BLUECORE_POINT_H
|
|
#define BLUECORE_POINT_H
|
|
|
|
#include "rectangle.h"
|
|
|
|
namespace BlueCore
|
|
{
|
|
template<typename type>
|
|
struct Rectangle2DTemplate;
|
|
|
|
template<typename type>
|
|
struct Point2DTemplate
|
|
{
|
|
type _x, _y;
|
|
|
|
Point2DTemplate() : _x(0), _y(0)
|
|
{
|
|
}
|
|
|
|
Point2DTemplate( type x, type y ) : _x(x), _y(y)
|
|
{
|
|
}
|
|
|
|
bool in( const Rectangle2DTemplate<type> &rect );
|
|
};
|
|
|
|
#include "rectangle.h"
|
|
|
|
template<typename type>
|
|
bool Point2DTemplate<type>::in( const Rectangle2DTemplate<type> &rect )
|
|
{
|
|
if( _x < rect._x )
|
|
return false;
|
|
|
|
if( _x > (rect._x + rect._width) )
|
|
return false;
|
|
|
|
if( _y < rect._y )
|
|
return false;
|
|
|
|
if( _y > (rect._y + rect._height) )
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
typedef Point2DTemplate<int> Point2D;
|
|
|
|
};
|
|
|
|
#endif
|