PIRL  PIRL++

Public Member Functions | Public Attributes | Static Public Attributes

PIRL::Point_2D Struct Reference

A Point_2D holds 2-dimensional position information. More...

#include <Dimensions.hh>

Inheritance diagram for PIRL::Point_2D:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 Point_2D ()
 Constructs a Point_2D at position 0,0.
 Point_2D (const Coordinate_Type &x, const Coordinate_Type &y)
 Constructs a Point_2D at position x,y.
 Point_2D (const Point_2D &point)
 Constructs a Point_2D from another Point_2D.
Point_2Dposition (const Coordinate_Type &x, const Coordinate_Type &y)
 Set the position of this Point_2D.
Point_2Dposition (const Point_2D &point)
 Set the position of this Point_2D.
Point_2Doperator= (const Point_2D &point)
 Assign the position of another Point_2D to this Point_2D.
Point_2Dx (const Coordinate_Type &x_position)
 Set the horizontal (x-axis) position.
Coordinate_Type x () const
 Get the horizontal (x-axis) position.
Point_2Dy (const Coordinate_Type &y_position)
 Set the vertical (y-axis) position.
Coordinate_Type y () const
 Get the vertical (y-axis) position.
bool operator== (const Point_2D &point) const
 Test if this Point_2D is equal to another Point_2D.
bool operator!= (const Point_2D &point) const
 Test if this Point_2D is not equal to another Point_2D.
 operator bool ()
 Test for all zero coordinate values.
bool is_null ()
 Test for all zero coordinate values.
Point_2Doperator+= (const Point_2D &offset)
 Add an offset.
Point_2Doperator-= (const Point_2D &offset)
 Subtract an offset.
Point_2Doperator*= (double factor)
 Multiply by a factor.
Point_2Doperator/= (double factor)
 Divide by a factor.

Public Attributes

Coordinate_Type X
 The horizontal (x-axis) position of the Point_2D.
Coordinate_Type Y
 The vertical (y-axis) position of the Point_2D.

Static Public Attributes

static const char *const ID = "PIRL::Dimensions ($Revision: 1.16 $ $Date: 2011/02/18 02:29:28 $)"
 Class identification name with source code version and date.

Detailed Description

A Point_2D holds 2-dimensional position information.

Author:
Bradford Castalia, UA/PIRL
Version:
Revision:
1.27

Constructor & Destructor Documentation

PIRL::Point_2D::Point_2D (  )

Constructs a Point_2D at position 0,0.

Referenced by PIRL::Rectangle::position().

PIRL::Point_2D::Point_2D ( const Coordinate_Type x,
const Coordinate_Type y 
)

Constructs a Point_2D at position x,y.

Parameters:
xThe horizontal (x-axis) position of the Point_2D.
yThe vertical (y-axis) position of the Point_2D.
PIRL::Point_2D::Point_2D ( const Point_2D point )

Constructs a Point_2D from another Point_2D.

Parameters:
pointA Point_2D to be copied.

Member Function Documentation

Point_2D& PIRL::Point_2D::position ( const Coordinate_Type x,
const Coordinate_Type y 
) [inline]

Set the position of this Point_2D.

Parameters:
xThe horizontal (x-axis) position of the Point_2D.
yThe vertical (y-axis) position of the Point_2D.
Returns:
This Point_2D.

Reimplemented in PIRL::Rectangle, and PIRL::Cube.

References x(), X, y(), and Y.

Point_2D& PIRL::Point_2D::position ( const Point_2D point ) [inline]

Set the position of this Point_2D.

Parameters:
pointA Point_2D whose coordinates are to be assigned to this Point_2D.
Returns:
This Point_2D.

Reimplemented in PIRL::Rectangle, and PIRL::Cube.

References X, and Y.

Point_2D& PIRL::Point_2D::operator= ( const Point_2D point ) [inline]

Assign the position of another Point_2D to this Point_2D.

Parameters:
pointA Point_2D whose coordinates are to be assigned to this Point_2D.

Reimplemented in PIRL::Rectangle, and PIRL::Cube.

References X, and Y.

Point_2D& PIRL::Point_2D::x ( const Coordinate_Type x_position ) [inline]

Set the horizontal (x-axis) position.

Parameters:
x_positionThe horizontal (x-axis) position of the Point_2D.
Returns:
This Point_2D.

References X.

Coordinate_Type PIRL::Point_2D::x (  ) const [inline]

Get the horizontal (x-axis) position.

Returns:
The horizontal (x-axis) position of the Point_2D.

References X.

Referenced by position().

Point_2D& PIRL::Point_2D::y ( const Coordinate_Type y_position ) [inline]

Set the vertical (y-axis) position.

Parameters:
y_positionThe vertical (y-axis) position of the Point_2D.
Returns:
This Point_2D.

References Y.

Coordinate_Type PIRL::Point_2D::y (  ) const [inline]

Get the vertical (y-axis) position.

Returns:
The vertical (y-axis) position of the Point_2D.

References Y.

Referenced by position().

bool PIRL::Point_2D::operator== ( const Point_2D point ) const [inline]

Test if this Point_2D is equal to another Point_2D.

The two Point_2Ds are equal if both their X and Y coordinates are equal.

Parameters:
pointThe Point_2D to which this Point_2D is to be compared.
Returns:
true if the two Point_2Ds are equal; false otherwise.

References X, and Y.

bool PIRL::Point_2D::operator!= ( const Point_2D point ) const [inline]

Test if this Point_2D is not equal to another Point_2D.

The two Point_2Ds are not equal if either their X or Y coordinates are not equal.

Parameters:
pointThe Point_2D to which this Point_2D is to be compared.
Returns:
true if the two Point_2Ds are not equal; false otherwise.

References X, and Y.

PIRL::Point_2D::operator bool (  ) [inline]

Test for all zero coordinate values.

Returns:
true if any coordinate value is non-zero; false otherwise.
See also:
is_null()

Reimplemented in PIRL::Rectangle, and PIRL::Cube.

References X, and Y.

bool PIRL::Point_2D::is_null (  ) [inline]

Test for all zero coordinate values.

Returns:
true if both coordinates are zero; false otherwise.
See also:
operator bool()

References X, and Y.

Point_2D& PIRL::Point_2D::operator+= ( const Point_2D offset ) [inline]

Add an offset.

Parameters:
offsetA Point_2D that provides the offset values.
Returns:
This Point_2D with its values offset.

Reimplemented in PIRL::Rectangle.

References X, and Y.

Point_2D& PIRL::Point_2D::operator-= ( const Point_2D offset ) [inline]

Subtract an offset.

Parameters:
offsetA Point_2D that provides the offset values.
Returns:
This Point_2D with its values offset.

Reimplemented in PIRL::Rectangle.

References X, and Y.

Point_2D& PIRL::Point_2D::operator*= ( double  factor ) [inline]

Multiply by a factor.

The new coordinate values will be rounded to the nearest Coordinate_Type values.

Parameters:
factorA factor by which to multiply the Point_2D coordinates.
Returns:
This Point_2D with its values changed.

Reimplemented in PIRL::Rectangle, and PIRL::Cube.

References PIRL::Round(), X, and Y.

Point_2D & PIRL::Point_2D::operator/= ( double  factor )

Divide by a factor.

The new coordinate values will be rounded to the nearest Coordinate_Type values.

N.B.: Divide by zero is handled as a special case. If the coordinate value was zero it will remain zero. If the Coordinate_Type has an infinity value (determined by numeric_types) that is used, or its negative if the coordinate value is negative. Otherwise, if the Coordinate_Type is signed the type's max value is used, or the min value if the coordinate value is negative; for an unsigned value the max value is used.

Parameters:
factorA factor by which to divide the Point_2D dimensions.
Returns:
This Point_2D with its values changed.

Reimplemented in PIRL::Rectangle, and PIRL::Cube.

References PIRL::Round().


Member Data Documentation

const char *const PIRL::Point_2D::ID = "PIRL::Dimensions ($Revision: 1.16 $ $Date: 2011/02/18 02:29:28 $)" [static]

Class identification name with source code version and date.

Referenced by PIRL::Size_2D::operator*=(), and PIRL::Size_2D::operator/=().


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