eRectangle Class Reference

the rectangle containing the arena More...

#include <eRectangle.h>

List of all members.

Public Member Functions

 eRectangle ()
 constructor to empty rectangle
 eRectangle (eCoord const &low, eCoord const &high)
 constructor
void Clear ()
 resets to empty state
eRectangleInclude (eCoord const &point)
 include the given point into the rectangle
bool Contains (eCoord const &point) const
 checks whether the given point lies inside the rectangle
REAL Clamp (eCoord &point) const
 clamps the point to lie inside the rectangle
REAL Clip (eCoord const &start, eCoord &stop) const
 clips stop to lie inside the rectangle without changing the direction start->stop
eCoord GetPoint (eCoord const &in) const
 returns a point in the interior
eCoord const & GetLow (void) const
 Gets low corner.
eRectangle const & GetLow (eCoord &low) const
 Gets low corner.
eCoord const & GetHigh (void) const
 Gets high corner.
eRectangle const & GetHigh (eCoord &high) const
 Gets high corner.

Private Member Functions

eRectangleSetLow (eCoord const &low)
 Sets low corner.
eRectangleSetHigh (eCoord const &high)
 Sets high corner.

Private Attributes

eCoord low_
 low corner
eCoord high_
 high corner


Detailed Description

the rectangle containing the arena

Definition at line 35 of file eRectangle.h.


Constructor & Destructor Documentation

eRectangle::eRectangle ( void   ) 

constructor to empty rectangle

Definition at line 41 of file eRectangle.cpp.

00042         : low_(1E+30, 1E+30), high_(-1E+30, -1E+30)
00043 {
00044 }

eRectangle::eRectangle ( eCoord const &  low,
eCoord const &  high 
)

constructor

Parameters:
low lowest part of the coordinates of the rectangle
high highest part of the coordinates of the rectangle

Definition at line 57 of file eRectangle.cpp.

00058         : low_(low), high_(high)
00059 {
00060 }


Member Function Documentation

void eRectangle::Clear ( void   ) 

resets to empty state

Definition at line 71 of file eRectangle.cpp.

References eCoord, high_, and low_.

Referenced by eWallRim::UpdateBounds().

00072 {
00073     low_ = eCoord(1E+30, 1E+30);
00074     high_ = eCoord(-1E+30, -1E+30);
00075 }

Here is the caller graph for this function:

eRectangle & eRectangle::Include ( eCoord const &  point  ) 

include the given point into the rectangle

Parameters:
point the point to include
Returns:
reference to this for chaining

Definition at line 88 of file eRectangle.cpp.

References high_, and low_.

Referenced by finite_xy_plane(), and eWallRim::UpdateBounds().

00089 {
00090     if (low_.x > point.x)
00091         low_.x = point.x;
00092     if (low_.y > point.y)
00093         low_.y = point.y;
00094     if (high_.x < point.x)
00095         high_.x = point.x;
00096     if (high_.y < point.y)
00097         high_.y = point.y;
00098 
00099     return *this;
00100 }

Here is the caller graph for this function:

bool eRectangle::Contains ( eCoord const &  point  )  const

checks whether the given point lies inside the rectangle

Parameters:
point the point to test
Returns:
true if the point lies inside

Definition at line 113 of file eRectangle.cpp.

References high_, and low_.

Referenced by eWallRim::IsBound().

00114 {
00115     return low_.x  <= point.x && low_.y  <= point.y &&
00116            high_.x >= point.x && high_.y >= point.y;
00117 }

Here is the caller graph for this function:

REAL eRectangle::Clamp ( eCoord &  point  )  const

clamps the point to lie inside the rectangle

Parameters:
point the point to clamp
Returns:
distance the point needed to be moved

Definition at line 140 of file eRectangle.cpp.

References high_, low_, REAL, and se_Clamp().

Referenced by eWallRim::Bound().

00141 {
00142     REAL ret = -1E+30;
00143     se_Clamp( point.x,  low_.x, -1, ret);
00144     se_Clamp( point.y,  low_.y, -1, ret);
00145     se_Clamp( point.x, high_.x,  1, ret);
00146     se_Clamp( point.y, high_.y,  1, ret);
00147 
00148     return ret;
00149 }

Here is the call graph for this function:

Here is the caller graph for this function:

REAL eRectangle::Clip ( eCoord const &  start,
eCoord &  stop 
) const

clips stop to lie inside the rectangle without changing the direction start->stop

Parameters:
start point (asserted to lie inside the rectangle) to serve as starting point
stop point to clip
Returns:
amount left of the start-stop line segment (1 for no clipping)

Definition at line 187 of file eRectangle.cpp.

References eCoord, high_, low_, REAL, and se_Clip().

Referenced by eWallRim::Clip().

00188 {
00189     // clip in x-direction
00190     REAL rx = se_Clip( start, stop, low_, eCoord(-1,0) );
00191     if ( rx >= 1 )
00192     {
00193         rx = se_Clip( start, stop, high_, eCoord(1,0) );
00194     }
00195 
00196     // clip in y-direction
00197     REAL ry = se_Clip( start, stop, low_, eCoord(0,-1) );
00198     if ( ry >= 1 )
00199     {
00200         ry = se_Clip( start, stop, high_, eCoord(0,1) );
00201     }
00202 
00203     return rx * ry;
00204 }

Here is the call graph for this function:

Here is the caller graph for this function:

eCoord eRectangle::GetPoint ( eCoord const &  in  )  const

returns a point in the interior

Parameters:
in coordinates in the range of 0..1 of the point to get
Returns:
point inside the rectangle

Definition at line 217 of file eRectangle.cpp.

References eCoord, high_, and low_.

Referenced by gArena::GetRandomPos().

00218 {
00219     eCoord diff = high_ - low_;
00220     return low_ + eCoord( diff.x * in.x, diff.y * in.y );
00221 }

Here is the caller graph for this function:

eCoord const & eRectangle::GetLow ( void   )  const [inline]

Gets low corner.

Returns:
low corner

Definition at line 74 of file eRectangle.h.

References low_.

Referenced by cWidget::Map::DrawMap(), cWidget::Map::DrawRimWalls(), finite_xy_plane(), and se_OffsetBounds().

00075 {
00076     return this->low_;
00077 }

Here is the caller graph for this function:

eRectangle const & eRectangle::GetLow ( eCoord &  low  )  const [inline]

Gets low corner.

Parameters:
low low corner to fill
Returns:
A reference to this to allow chaining

Definition at line 90 of file eRectangle.h.

References low_.

00091 {
00092     low = this->low_;
00093     return *this;
00094 }

eCoord const & eRectangle::GetHigh ( void   )  const [inline]

Gets high corner.

Returns:
high corner

Definition at line 123 of file eRectangle.h.

References high_.

Referenced by cWidget::Map::DrawMap(), cWidget::Map::DrawRimWalls(), finite_xy_plane(), and se_OffsetBounds().

00124 {
00125     return this->high_;
00126 }

Here is the caller graph for this function:

eRectangle const & eRectangle::GetHigh ( eCoord &  high  )  const [inline]

Gets high corner.

Parameters:
high high corner to fill
Returns:
A reference to this to allow chaining

Definition at line 139 of file eRectangle.h.

References high_.

00140 {
00141     high = this->high_;
00142     return *this;
00143 }

eRectangle & eRectangle::SetLow ( eCoord const &  low  )  [inline, private]

Sets low corner.

Parameters:
low low corner to set
Returns:
A reference to this to allow chaining

Definition at line 107 of file eRectangle.h.

References low_.

00108 {
00109     this->low_ = low;
00110     return *this;
00111 }

eRectangle & eRectangle::SetHigh ( eCoord const &  high  )  [inline, private]

Sets high corner.

Parameters:
high high corner to set
Returns:
A reference to this to allow chaining

Definition at line 156 of file eRectangle.h.

References high_.

00157 {
00158     this->high_ = high;
00159     return *this;
00160 }


Member Data Documentation

eCoord eRectangle::low_ [private]

low corner

Definition at line 49 of file eRectangle.h.

Referenced by Clamp(), Clear(), Clip(), Contains(), GetLow(), GetPoint(), Include(), and SetLow().

eCoord eRectangle::high_ [private]

high corner

Definition at line 50 of file eRectangle.h.

Referenced by Clamp(), Clear(), Clip(), Contains(), GetHigh(), GetPoint(), Include(), and SetHigh().


The documentation for this class was generated from the following files:
Generated on Sat Mar 15 23:29:17 2008 for Armagetron Advanced by  doxygen 1.5.4