MFMv2.0.10
Movable Feast Machine Simulator 2.0.10
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Friends
MFM::Point< T > Class Template Reference

#include <Point.h>

Public Member Functions

 Point ()
 
 Point (T x, T y)
 
 Point (const Point< T > &p)
 
 Point (Random &random, T maxX, T maxY)
 
 ~Point ()
 
GetX () const
 
GetY () const
 
u32 GetManhattanLength () const
 
u32 GetMaximumLength () const
 
double GetEuclideanLength () const
 
void Clear ()
 
void Add (const Point< T > &offset)
 
void Add (T x, T y)
 
void Subtract (const Point< T > &offset)
 
void Subtract (T x, T y)
 
void Multiply (T scalar)
 
void Divide (T scalar)
 
void Mod (T scalar)
 
void SetX (T x)
 
void SetY (T y)
 
void Set (T x, T y)
 
void Set (const Point< T > &copyFrom)
 
bool Equals (const Point< T > &rhs) const
 
bool BoundedBelow (const Point< T > &bound) const
 
bool BoundedAbove (const Point< T > &bound) const
 
bool BoundedBy (const Point< T > &lowerBound, const Point< T > &upperBound) const
 
bool IsZero () const
 
void Parse (char *buffer)
 
Point< T > & operator= (const Point< T > &rhs)
 
Point< T > & operator+= (const Point< T > &rhs)
 
Point< T > & operator-= (const Point< T > &rhs)
 
Point< T > & operator*= (const s32 rhs)
 
Point< T > & operator/= (const s32 rhs)
 

Friends

Point< T > max (const Point< T > &lhs, const Point< T > &rhs)
 
Point< T > min (const Point< T > &lhs, const Point< T > &rhs)
 
Point< T > operator+ (const Point< T > &lhs, const Point< T > &rhs)
 
Point< T > operator- (const Point< T > &lhs, const Point< T > &rhs)
 
bool operator== (const Point< T > &lhs, const Point< T > &rhs)
 
bool operator!= (const Point< T > &lhs, const Point< T > &rhs)
 
Point< T > operator* (const Point< T > &lhs, const s32 rhs)
 
Point< T > operator/ (const Point< T > &lhs, const s32 rhs)
 
Point< T > operator% (const Point< T > &lhs, const s32 rhs)
 

Detailed Description

template<class T>
class MFM::Point< T >

Two-dimension integral coordinates template class. Primary uses are UPoint – two unsigned 32 bit numbers – and SPoint – two signed 32 bit numbers.

Constructor & Destructor Documentation

template<class T >
MFM::Point< T >::Point ( )

Constructs a new Point whose coordinates are initially set to 0 .

template<class T>
MFM::Point< T >::Point ( x,
y 
)

Constructs a new Point whose coordinates are set from specified values.

Parameters
xThe initial x value of this Point .
yThe initial y value of this Point .
template<class T>
MFM::Point< T >::Point ( const Point< T > &  p)

Constructs a new Point from another Point, copying its coordinates.

Parameters
pThe Point to copy the coordinates of.
template<class T>
MFM::Point< T >::Point ( Random random,
maxX,
maxY 
)

Constructs a new Point with randomly chosen coordinates, between 0 and a specified maximum value .

Parameters
randomThe PRNG used to choose the random numbers for the coordinates of the new Point .
maxXThe maximum X value that can be chosen by random .
maxYThe maximum Y value that can be chosen by random .
template<class T>
MFM::Point< T >::~Point ( )
inline

Deconstructs this Point .

Member Function Documentation

template<class T>
void MFM::Point< T >::Add ( const Point< T > &  offset)

Adds another Point to this Point , storing the result in this Point .

Parameters
offsetThe Point to add to this Point .
template<class T>
void MFM::Point< T >::Add ( x,
y 
)

Adds a pair of given coordinates to the coordinates in this Point .

Parameters
xThe x coordinate to add to this Point .
yThe y coordinate to add to this Point .
template<class T>
bool MFM::Point< T >::BoundedAbove ( const Point< T > &  bound) const

Checks to see that the coordinates in this Point are both less than or equal to the coordinates in another Point .

Parameters
boundThe Point to check boundedness against.
Returns
true if the coordinates in this Point are both less than or equal to the respective coordinates in bound .
template<class T>
bool MFM::Point< T >::BoundedBelow ( const Point< T > &  bound) const

Checks to see that the coordinates in this Point are both greater than or equal to the coordinates in another Point .

Parameters
boundThe Point to check boundedness against.
Returns
true if the coordinates in this Point are both greater than or equal to the respective coordinates in bound .
template<class T>
bool MFM::Point< T >::BoundedBy ( const Point< T > &  lowerBound,
const Point< T > &  upperBound 
) const

Checks to see that the coordinates in this Point are bounded both by a Point representing a lower bound and a Point representing an upper bound; i.e.

BoundedBelow(lowerBound) && BoundedAbove(upperBound)
Parameters
lowerBoundThe Point representing the lower bound of this test.
upperBoundThe Point representing the upper bound of this test.
Returns
true if this Point is bounded by the two parameters, else false .
template<class T>
void MFM::Point< T >::Clear ( )
inline

Sets the held coordinates of this Point to 0 .

template<class T>
void MFM::Point< T >::Divide ( scalar)

Divides the held coordinates of this Point by a specified scalar value.

Parameters
scalarThe scalar value used to divide the coordinates in this Point .
template<class T>
bool MFM::Point< T >::Equals ( const Point< T > &  rhs) const

Checks for equality between this Point and a similarly typed Point .

Parameters
rhsThe Point to check equality against this Point .
Returns
true if rhs is considered to be equal to this Point , else false.
template<class T >
double MFM::Point< T >::GetEuclideanLength ( ) const

Gets the absolute distance of this Point from the origin using the pythagorean theorem.

Returns
The length of the vector held by this Point .
template<class T >
u32 MFM::Point< T >::GetManhattanLength ( ) const

Gets the Manhattan Distance from the origin to the ends of the vector represented by this Point .

Returns
The Manhattan Distance of this Point .
Remarks
Would prefer 'unsigned T' return type but not using C++0x type_traits
template<class T >
u32 MFM::Point< T >::GetMaximumLength ( ) const

Gets the maximum of the x and y coordinates and returns the largest one; i.e. MAX(x,y) .

Returns
The maximum of the coordinates in this Point .
template<class T >
T MFM::Point< T >::GetX ( ) const

Gets the x coordinate of this Point .

Returns
The x coordinate of this Point .
template<class T >
T MFM::Point< T >::GetY ( ) const

Gets the y coordinate of this Point .

Returns
The y coordinate of this Point .
template<class T>
bool MFM::Point< T >::IsZero ( ) const
inline

Checks to see if the coordinates held by this Point are both 0 .

Returns
true if both coordinates in this Point are equal to 0 .
template<class T>
void MFM::Point< T >::Mod ( scalar)

Performs the modulus operation on the coordinates of this Point by a specified scalar value .

Parameters
scalarThe scalar value used to mod the coordinates of this Point .
template<class T>
void MFM::Point< T >::Multiply ( scalar)

Multiplies the held coordinates of this Point by a specified scalar value.

Parameters
scalarThe scalar value used to multiply the coordinates in this Point .
template<class T>
Point<T>& MFM::Point< T >::operator*= ( const s32  rhs)
inline

Multiplies the coordinates of this Point by a specified integral scalar.

Parameters
rhsThe scalar to multiply the coordinates of this Point by.
Returns
A reference to this Point.
template<class T>
Point<T>& MFM::Point< T >::operator+= ( const Point< T > &  rhs)
inline

Adds the coordinates of a Point to the coordinates of this Point .

Parameters
rhsThe Point to add to this Point.
Returns
A reference to this Point .
template<class T>
Point<T>& MFM::Point< T >::operator-= ( const Point< T > &  rhs)
inline

Subtracts the coordinates of a Point from the coordinates of this Point .

Parameters
rhsThe Point to subtract from this Point.
Returns
A reference to this Point .
template<class T>
Point<T>& MFM::Point< T >::operator/= ( const s32  rhs)
inline

Divides the coordinates of this Point by a specified integral scalar.

Parameters
rhsThe scalar to divide the coordinates of this Point by.
Returns
A reference to this Point.
template<class T>
Point< T > & MFM::Point< T >::operator= ( const Point< T > &  rhs)

Copies the coordinates from a specified Point to this Point .

Parameters
rhsThe Point to copy coordinates from.
Returns
A refrence to this Point .
template<class T >
void MFM::Point< T >::Parse ( char *  buffer)

Parses a char* for a Point of {integral} type in the format "(x,y)" with no whitespace. This treats any read values as (T)atoi(x) and (T)atoi(y), so make sure that casting from a call of atoi won't break anything.

Parameters
bufferThe char* to parse a point directly from.
template<class T>
void MFM::Point< T >::Set ( x,
y 
)

Sets the x and y values of this Point to specified coordinates .

Parameters
xThe new x value of this Point .
yThe new y value of this Point .
template<class T>
void MFM::Point< T >::Set ( const Point< T > &  copyFrom)

Sets the x and y values of this Point to the coordinates stored in another Point .

Parameters
copyFromThe Point to copy the values of to this Point .
template<class T>
void MFM::Point< T >::SetX ( x)

Sets the x value of this Point to a specified value .

Parameters
xThe new x value of this Point .
template<class T>
void MFM::Point< T >::SetY ( y)

Sets the y value of this Point to a specified value .

Parameters
yThe new y value of this Point .
template<class T>
void MFM::Point< T >::Subtract ( const Point< T > &  offset)

Subtracts another Point from this Point , storing the result in this Point .

Parameters
offsetThe Point to subtract from this Point .
template<class T>
void MFM::Point< T >::Subtract ( x,
y 
)

Subtracts a pair of given coordinates from the coordinates in this Point .

Parameters
xThe x coordinate to subtract from this Point .
yThe y coordinate to subtract from this Point .

Friends And Related Function Documentation

template<class T>
Point<T> max ( const Point< T > &  lhs,
const Point< T > &  rhs 
)
friend

Creates a Point consisting of the maximum x coordinate of two Points and the maximum y coordinate of two Points.

Parameters
lhsOne of the Points used to construct this maximum Point .
rhsThe other Point used to construct this maximum Point .
Returns
A Point consisting of the maximum x coordinate and maximum y coordinate of lhs and rhs .
template<class T>
Point<T> min ( const Point< T > &  lhs,
const Point< T > &  rhs 
)
friend

Creates a Point consisting of the minimum x coordinate of two Points and the minimum y coordinate of two Points.

Parameters
lhsOne of the Points used to construct this minimum Point .
rhsThe other Point used to construct this minimum Point .
Returns
A Point consisting of the minimum x coordinate and minimum y coordinate of lhs and rhs .
template<class T>
bool operator!= ( const Point< T > &  lhs,
const Point< T > &  rhs 
)
friend

Checks to see that a Point is considered not to be equal to another Point .

Parameters
lhsOne Point to check for inequality.
rhsThe other Point to check for inequality.
Returns
true if lhs is considered to be inequal to rhs , else false .
template<class T>
Point<T> operator% ( const Point< T > &  lhs,
const s32  rhs 
)
friend

Constructs a new Point consisting of the remainder of the division between coordinates of one Point and an integral scalar.

Parameters
lhsThe dividend Point used to construct the new Point .
rhsThe divisor scalar used to construct the new Point .
Returns
The Point which is the remainder of the division between the coordinates of lhs and the scalar rhs .
template<class T>
Point<T> operator* ( const Point< T > &  lhs,
const s32  rhs 
)
friend

Constructs a new Point consisting of the coordinates of one Point multiplied by an integral scalar.

Parameters
lhsThe multiplicand Point used to construct the new Point .
rhsThe multiplier scalar used to construc the new Point
Returns
The Point which is the product of the coordinates of lhs and the scalar rhs .
template<class T>
Point<T> operator+ ( const Point< T > &  lhs,
const Point< T > &  rhs 
)
friend

Creates a new Point consisting of the sum of the coordinates of two given points.

Parameters
lhsThe augend Point used to construct the summed Point .
rhsThe addend Point used to construct the summed Point .
Returns
The Point consisting of the sum of the coordinates in lhs and rhs .
template<class T>
Point<T> operator- ( const Point< T > &  lhs,
const Point< T > &  rhs 
)
friend

Creates a new Point consisting of the difference of the coordinates of two given points.

Parameters
lhsThe minuend Point used to construct the differenced Point .
rhsThe subtrahend Point used to construct the summed Point .
Returns
The Point consisting of the difference of the coordinates in lhs and rhs .
template<class T>
Point<T> operator/ ( const Point< T > &  lhs,
const s32  rhs 
)
friend

Constructs a new Point consisting of the coordinates of one Point divided by an integral scalar.

Parameters
lhsThe dividend Point used to construct the new Point .
rhsThe divisor scalar used to construct the new Point .
Returns
The Point which is the quotient of the coordinates of lhs and the scalar rhs .
template<class T>
bool operator== ( const Point< T > &  lhs,
const Point< T > &  rhs 
)
friend

Checks to see that a Point is considered to be equal to another Point .

Parameters
lhsOne Point to check for equality.
rhsThe other Point to check for equality.
Returns
true if lhs is considered to be equal to rhs , else false .

The documentation for this class was generated from the following files: