hex::Edge Class Reference

#include <hex.h>

List of all members.


Detailed Description

The interface between a hex and one of its six neighbours.

Length K. Each hex has its OWN set of edges, so each hex-hex interface has TWO edges- one for each hex.

Definition at line 238 of file hex.h.

Public Member Functions

Hexhex (void) const
Direction direction (void) const
Edgecomplement (void) const
bool is_next (const Edge &v) const
Edgenext_in (bool clockwise=false) const
Edgenext_out (bool clockwise=false) const
Point start_point (float bias=0.0, bool clockwise=false) const
Point end_point (float bias=0.0, bool clockwise=false) const
Point join_point (const Edge *next, float bias=0.0) const

Friends

class Hex


Member Function Documentation

Hex* hex::Edge::hex ( void   )  const [inline]

Definition at line 243 of file hex.h.

Referenced by hex::Grid::boundary(), hex::Area::boundary(), and hex::move::Topography::increase_edge_cost().

00243 { return _hex; }

Direction hex::Edge::direction ( void   )  const [inline]

Definition at line 244 of file hex.h.

Referenced by hex::Grid::boundary().

00244 { return _direction; }

Edge * hex::Edge::complement ( void   )  const

Definition at line 32 of file edge.cc.

References hex::Hex::edge(), and hex::Hex::go().

Referenced by next_out().

00033 {
00034   Hex* adjacent_hex =_hex->go(_direction);
00035   if(adjacent_hex)
00036       return adjacent_hex->edge(_direction+3);
00037   else
00038       return NULL;
00039 }

bool hex::Edge::is_next ( const Edge v  )  const

Definition at line 43 of file edge.cc.

References _direction, _hex, and next_out().

00044 {
00045   // TRUE iff: &v == next_in(T) || next_in(F) || next_out(T) || next_out(F)
00046   if( _hex == v._hex )
00047       return( _direction+1 == v._direction || _direction-1 == v._direction );
00048   else
00049       return( &v == next_out(true) || &v == next_out(false) );
00050 }

Edge * hex::Edge::next_in ( bool  clockwise = false  )  const

Definition at line 54 of file edge.cc.

References hex::Hex::edge().

Referenced by hex::Grid::boundary(), hex::Area::boundary(), and hex::Boundary::clockwise().

00055 {
00056   int one =(clockwise? -1: 1);
00057   return _hex->edge( _direction + one );
00058 }

Edge * hex::Edge::next_out ( bool  clockwise = false  )  const

Definition at line 62 of file edge.cc.

References _hex, complement(), and hex::Hex::edge().

Referenced by hex::Grid::boundary(), hex::Boundary::clockwise(), is_next(), and join_point().

00063 {
00064   int one =(clockwise? -1: 1);
00065   Edge* c =_hex->edge( _direction + one )->complement();
00066   if(c)
00067       return c->_hex->edge( _direction - one );
00068   else
00069       return NULL;
00070 }

Point hex::Edge::start_point ( float  bias = 0.0,
bool  clockwise = false 
) const

Definition at line 95 of file edge.cc.

References hex::Hex::centre(), and hex::corner_offset().

Referenced by end_point(), and join_point().

00096 {
00097   if(clockwise)
00098       return corner_offset( _hex->centre(), _direction + 1, bias );
00099   else
00100       return corner_offset( _hex->centre(), _direction    , bias );
00101 }

Point hex::Edge::end_point ( float  bias = 0.0,
bool  clockwise = false 
) const

Definition at line 105 of file edge.cc.

References start_point().

Referenced by join_point(), and hex::Boundary::stroke().

00106 {
00107   return start_point(bias,!clockwise);
00108 }

Point hex::Edge::join_point ( const Edge next,
float  bias = 0.0 
) const

Definition at line 112 of file edge.cc.

References _direction, _hex, hex::Hex::centre(), hex::corner_offset(), end_point(), next_out(), and start_point().

Referenced by hex::Boundary::stroke().

00113 {
00114   if(bias==0.0 || this->_hex==next->_hex)
00115   {
00116     if(this->_direction+1 == next->_direction)
00117         return end_point(bias);
00118     else
00119         return start_point(bias); // clockwise
00120   }
00121   else if(next == next_out())
00122   {
00123     Point p =corner_offset( _hex->centre(), _direction + 2, 0.0 );
00124     return corner_offset( p, _direction, bias );
00125   }
00126   else // clockwise
00127   {
00128 #ifdef HEX_PARANOID_CHECKS
00129     assert(next == next_out(true));
00130 #endif
00131     Point p =corner_offset( _hex->centre(), _direction - 1, 0.0 );
00132     return corner_offset( p, _direction + 1, bias );
00133   }
00134 }


Friends And Related Function Documentation

friend class Hex [friend]

Definition at line 253 of file hex.h.


The documentation for this class was generated from the following files:
Generated on Thu Feb 21 00:00:55 2008 for libhex by  doxygen 1.5.1