Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

SgPointUtil Namespace Reference


Classes

class  PointToRow
 Lookup table internally used by SgPointUtil::Row(). More...
class  PointToCol
 Lookup table internally used by SgPointUtil::Col(). More...

Functions

std::string PointToString (SgPoint p)
SgPoint Rotate (int rotation, SgPoint p, int size)
 Rotate/mirror point.
int InvRotation (int rotation)
 Return the inverse rotation as used in SgPointUtil::Rotate.
char Letter (int coord)
SgPoint Pt (int col, int row)
 Converts from (col, row) to a one-dimensional point.
SgGrid Col (SgPoint p)
 Return column of point.
SgGrid Row (SgPoint p)
 Return row of point.
bool InBoardRange (SgPoint p)
bool AreAdjacent (SgPoint p1, SgPoint p2)
 True if the two points are adjacent to each other.
bool AreDiagonal (SgPoint p1, SgPoint p2)
 True if the two points are diagonally adjacent to each other.
int Distance (SgPoint p1, SgPoint p2)
 Manhattan distance between two points on the board.
bool In8Neighborhood (SgPoint p1, SgPoint p2)
 p2 is in 3x3 area around p1.


Function Documentation

std::string SgPointUtil::PointToString ( SgPoint  p  ) 

Definition at line 18 of file SgPoint.cpp.

References Col(), Letter(), Row(), SG_COUPONMOVE, SG_COUPONMOVE_VIRTUAL, SG_NULLMOVE, SG_PASS, and SG_RESIGN.

Referenced by operator<<().

SgPoint SgPointUtil::Rotate ( int  rotation,
SgPoint  p,
int  size 
)

Rotate/mirror point.

Rotates and/or mirrors a point on a given board according to a given rotation mode.
Modecolrow
0colrow
1size - col + 1row
2colsize - row + 1
3rowcol
4size - row + 1col
5rowsize - col + 1
6size - col + 1size - row + 1
7size - row + 1size - col + 1

Parameters:
rotation The rotation mode in [0..7]
p The point to be rotated (SG_PASS is allowed and returned unmodified)
size The board size
Returns:
The rotated mirrored point

Definition at line 36 of file SgPoint.cpp.

References Col(), Pt(), Row(), SG_ASSERT, and SG_PASS.

Referenced by SgPointSetUtil::Rotate().

int SgPointUtil::InvRotation ( int  rotation  ) 

Return the inverse rotation as used in SgPointUtil::Rotate.

Parameters:
rotation The rotation mode in [0..7]
Returns:
The inverse rotation mode

Definition at line 67 of file SgPoint.cpp.

References SG_ASSERT.

char SgPointUtil::Letter ( int  coord  ) 

Definition at line 204 of file SgPoint.h.

Referenced by PointToString(), and SgEvaluatedMovesArray::Write().

SgPoint SgPointUtil::Pt ( int  col,
int  row 
)

Converts from (col, row) to a one-dimensional point.

Only for on board points; will trigger assertion for off-board points.

Definition at line 280 of file SgPoint.h.

References SG_ASSERT_GRIDRANGE, and SG_NS.

Referenced by SgBoardConst::BoardConstImpl::BoardConstImpl(), SgRect::Center(), SgPointSet::CheckedContains(), InBoardRange(), SgPointUtil::PointToCol::PointToCol(), SgPointUtil::PointToRow::PointToRow(), SgNb4Iterator::Precomp::Precomp(), SgPointSet::PrecompAllPoints::PrecompAllPoints(), SgReadPointSet::Read(), SgReadPoint::Read(), Rotate(), SgPropUtil::SgfStringToPoint(), SgPointSet::Write(), SgWritePointArrayFloat< FLOAT >::Write(), SgWritePointArray< T >::Write(), and SgEvaluatedMovesArray::Write().

SgGrid SgPointUtil::Col ( SgPoint  p  ) 

Return column of point.

The lower left corner of the coordinate grid is (1, 1).

Definition at line 262 of file SgPoint.h.

References SgPointUtil::PointToCol::Col().

Referenced by Distance(), SgRect::Include(), SgRect::InRect(), MaxDistance(), SgRectIterator::operator++(), SgPropUtil::PointToSgfString(), PointToString(), and Rotate().

SgGrid SgPointUtil::Row ( SgPoint  p  ) 

Return row of point.

The lower left corner of the coordinate grid is (1, 1).

Definition at line 271 of file SgPoint.h.

References SgPointUtil::PointToRow::Row().

Referenced by Distance(), SgRect::Include(), SgRect::InRect(), MaxDistance(), SgPropUtil::PointToSgfString(), PointToString(), and Rotate().

bool SgPointUtil::InBoardRange ( SgPoint  p  ) 

Definition at line 287 of file SgPoint.h.

References SgUtil::InRange(), Pt(), and SG_MAX_SIZE.

Referenced by SgEvaluatedMovesArray::AddMove(), SgEvaluatedMoves::AddMove(), SgMiaiStrategy::AddPair(), SgPropTextList::FromString(), SgPropPointList::FromString(), SgEvaluatedMovesArray::ReduceMove(), SgNb4DiagIterator::SgNb4DiagIterator(), SgNb4Iterator::SgNb4Iterator(), and SgNb8Iterator::SgNb8Iterator().

bool SgPointUtil::AreAdjacent ( SgPoint  p1,
SgPoint  p2 
)

True if the two points are adjacent to each other.

Definition at line 293 of file SgPoint.h.

References SG_NS, and SG_WE.

bool SgPointUtil::AreDiagonal ( SgPoint  p1,
SgPoint  p2 
)

True if the two points are diagonally adjacent to each other.

Definition at line 300 of file SgPoint.h.

References SG_NS, and SG_WE.

int SgPointUtil::Distance ( SgPoint  p1,
SgPoint  p2 
)

Manhattan distance between two points on the board.

Definition at line 307 of file SgPoint.h.

References Col(), and Row().

Referenced by SgPointSet::Center().

bool SgPointUtil::In8Neighborhood ( SgPoint  p1,
SgPoint  p2 
)

p2 is in 3x3 area around p1.

Definition at line 314 of file SgPoint.h.

References SG_NS, and SG_WE.


17 Jun 2010 Doxygen 1.4.7