obj.cc
//***********************************************************************
// MODULE : Obj - Class Body *
// AUTHOR : Ron Chernich *
// PURPOSE: Class supporting geometric objects used by RCOS *
// HISTORY: *
// 18-JAN-93 First (MSC/C++ 7.00) version *
//***********************************************************************
#include "obj.hh"
/////////////
// very simple little 'critta makes no real assumptions about anything
//
point::point (INT16 n1, INT16 n2)
{
x = n1, y = n2;
}
///////////////
// Assignment operator
//
point& point::operator = (point &pt)
{
x = pt.x, y = pt.y;
return *this;
}
//////////////
// assuming THIS (lvalue) is the origin,
// RETURNS: TRUE .. point lies in second quadrent or on an axis boundary
// FALSE .. point (rvalue) lies inside other three quadrents
//
BOOL point::operator >= (point &pt)
{
return (BOOL)((x >= pt.x) && (y >= pt.y));
}
//////////////
// assuming THIS (lvalue) is the origin,
// RETURNS: TRUE .. point on bounding axis or inside quadrents 1, 3 or 4
// FALSE .. point (rvalue) lies inside second quadrent
//
BOOL point::operator <= (point &pt)
{
return (BOOL)((x <= pt.x) && (y <= pt.y));
}
void point::MovePt (INT16 n1, INT16 n2)
{
x = n1, y = n2;
}
///////////////////
// Rectangle constructors with args..
//
rect::rect (point &pt1, point &pt2)
{
ul = pt1, lr = pt2;
}
rect::rect (point &pt1, INT16 n1, INT16 n2)
{
point pt2(n1, n2);
ul = pt1, lr = pt2;
}
rect::rect (INT16 n1, INT16 n2, INT16 n3, INT16 n4)
{
point pt1(n1, n2), pt2(n3, n4);
ul = pt1, lr = pt2;
}
///////////////////
// RETURNS: TRUE if passed point is within the rectangle
//
BOOL rect::InRect (point &pt)
{
return (BOOL)((pt >= ul) && (pt <= lr));
}
/************************************ EOF ********************************/