PIRL  PIRL++

Public Member Functions | Public Attributes

PIRL::Cube Struct Reference

A Cube is a Rectangle with depth. More...

#include <Dimensions.hh>

Inheritance diagram for PIRL::Cube:
Inheritance graph
[legend]
Collaboration diagram for PIRL::Cube:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Cube ()
 Constructs an empty Cube.
 Cube (const Coordinate_Type x, const Coordinate_Type y, const Dimensions_Type width=0, const Dimensions_Type height=0, const Dimensions_Type depth=0)
 Constructs a Cube from an x,y position, width,height size, and depth.
 Cube (const Point_2D &position, const Size_2D &size)
 Constructs a Cube from a position and a size.
 Cube (const Size_2D &size)
 Constructs a Cube from a size.
 Cube (const Rectangle &rectangle)
 Constructs a Cube from a Rectangle.
 Cube (const Cube &cube)
 Constructs a Cube as a copy of another Cube.
Cubeposition (const Coordinate_Type &x, const Coordinate_Type &y)
 Set the position of this Cube.
Cubeposition (const Point_2D &point)
 Set the position of this Cube.
Cubeoperator= (const Point_2D &point)
 Assign the position of the Cube from a Point_2D.
Cubesize (const Dimensions_Type &width, const Dimensions_Type &height)
 Set the size of this Cube.
Cubesize (const Size_2D &size)
 Set the size of this Cube.
Cubedepth (Dimensions_Type depth)
 Set the Depth of this Cube.
Dimensions_Type depth () const
 Get the Depth of this Cube.
Cubeoperator= (const Size_2D &size)
 Assign the size of the Cube from a Size_2D.
Cubedimensions (const Rectangle &rectangle)
 Set the dimensions of this Cube from a Rectangle.
Cubeoperator= (const Rectangle &rectangle)
 Set the dimensions of this Cube from a Rectangle.
Cubeoperator= (const Cube &cube)
 Assign the dimensions of another Cube to this Cube.
unsigned long long volume () const
 Get the volume of this Cube.
bool operator== (const Cube &cube) const
 Test if this Cube is equal to another Cube.
bool operator!= (const Cube &cube) const
 Test if this Cube is not equal to another Cube.
 operator bool ()
 Test for all zero dimension values.
bool is_empty ()
 Test for any zero dimension values.
Cubeoperator+= (int amount)
 Add an amount to the Cube Depth.
Cubeoperator+= (const Cube &cube)
 Add another Cube's point coordinate offset, and depth and size amount.
Cubeoperator-= (int amount)
 Subtract an amount from the Cube Depth.
Cubeoperator-= (const Cube &cube)
 Subtract another Cube's point coordinate and depth offset and size amount.
Cubeoperator*= (double factor)
 Multiply by a factor.
Cubeoperator/= (double factor)
 Divide by a factor.
Cubeoperator&= (const Cube &cube)
 Take the intersection with another Cube.
Cubeoperator|= (const Cube &cube)
 Take the union with another Cube.

Public Attributes

Dimensions_Type Depth
 The Depth of the Cube.

Detailed Description

A Cube is a Rectangle with depth.

A Cube does not have a Z-dimension position. Instead it has a Depth with the position of the Cube having an implicit Z-coordinate of zero; i.e. the facing surface of the Cube defined by its Rectangle is at the Z-coordinate origin with the Z-axis Depth increasing away from the observer (right handed coordinate system).

Author:
Bradford Castalia, UA/PIRL
Version:
Revision:
1.27
See also:
Rectangle

Constructor & Destructor Documentation

PIRL::Cube::Cube (  )

Constructs an empty Cube.

The position is 0,0; the size is 0,0; the Depth is 0.

PIRL::Cube::Cube ( const Coordinate_Type  x,
const Coordinate_Type  y,
const Dimensions_Type  width = 0,
const Dimensions_Type  height = 0,
const Dimensions_Type  depth = 0 
)

Constructs a Cube from an x,y position, width,height size, and depth.

Parameters:
xThe horizontal (x-axis) position.
yThe vertical (y-axis) position.
widthThe Width of the Cube.
heightThe Height of the Cube.
depthThe Depth of the Cube.
PIRL::Cube::Cube ( const Point_2D position,
const Size_2D size 
)

Constructs a Cube from a position and a size.

The Cube will have a Depth of 1.

Parameters:
positionA Point_2D.
sizeA Size_2D.
PIRL::Cube::Cube ( const Size_2D size )

Constructs a Cube from a size.

The Cube will have a position of 0,0 and a Depth of 1.

Parameters:
sizeA Size_2D.
PIRL::Cube::Cube ( const Rectangle rectangle )

Constructs a Cube from a Rectangle.

The Cube will have a Depth of 1.

Parameters:
rectangleA Rectangle.
PIRL::Cube::Cube ( const Cube cube )

Constructs a Cube as a copy of another Cube.

Parameters:
cubeA Cube to be copied.

Member Function Documentation

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

Set the position of this Cube.

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

Reimplemented from PIRL::Rectangle.

References PIRL::Rectangle::position().

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

Set the position of this Cube.

Parameters:
pointA Point_2D whose dimensions are to be assigned as the position of this Cube.
Returns:
This Cube.

Reimplemented from PIRL::Rectangle.

References PIRL::Rectangle::position().

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

Assign the position of the Cube from a Point_2D.

Parameters:
pointA Point_2D for the position of the Cube.
Returns:
This Cube.

Reimplemented from PIRL::Rectangle.

Referenced by dimensions(), and operator=().

Cube& PIRL::Cube::size ( const Dimensions_Type width,
const Dimensions_Type height 
) [inline]

Set the size of this Cube.

Parameters:
widthThe Width of the Cube.
heightThe Height of the Cube.
Returns:
This Cube.

Reimplemented from PIRL::Rectangle.

References PIRL::Rectangle::size().

Cube& PIRL::Cube::size ( const Size_2D size ) [inline]

Set the size of this Cube.

Parameters:
sizeA Size_2D to have its dimensions assigned to this Cube.
Returns:
This Cube.

Reimplemented from PIRL::Rectangle.

References PIRL::Rectangle::size().

Cube& PIRL::Cube::depth ( Dimensions_Type  depth ) [inline]

Set the Depth of this Cube.

Parameters:
depthThe Depth of this Cube.
Returns:
This Cube.

References depth(), and Depth.

Referenced by depth().

Dimensions_Type PIRL::Cube::depth (  ) const [inline]

Get the Depth of this Cube.

Returns:
The Depth of this Cube.

References Depth.

Cube& PIRL::Cube::operator= ( const Size_2D size ) [inline]

Assign the size of the Cube from a Size_2D.

Parameters:
sizeA Size_2D for the size of the Cube.
Returns:
This Cube.

Reimplemented from PIRL::Rectangle.

References operator=().

Cube& PIRL::Cube::dimensions ( const Rectangle rectangle ) [inline]

Set the dimensions of this Cube from a Rectangle.

Parameters:
rectangleA Rectangle to have its dimensions assigned to this Cube.
Returns:
This Cube.

References operator=().

Cube& PIRL::Cube::operator= ( const Rectangle rectangle ) [inline]

Set the dimensions of this Cube from a Rectangle.

Parameters:
rectangleA Rectangle to have its dimensions assigned to this Cube.
Returns:
This Cube.

Reimplemented from PIRL::Rectangle.

References operator=().

Cube& PIRL::Cube::operator= ( const Cube cube ) [inline]

Assign the dimensions of another Cube to this Cube.

Parameters:
cubeA Cube whose dimensions are be assigned to this Cube.
Returns:
This Cube.

References Depth, PIRL::Size_2D::Height, PIRL::Size_2D::Width, PIRL::Point_2D::X, and PIRL::Point_2D::Y.

unsigned long long PIRL::Cube::volume (  ) const [inline]

Get the volume of this Cube.

Returns:
The volume (Width * Height * Depth) of the Cube.

References PIRL::Size_2D::area(), and Depth.

bool PIRL::Cube::operator== ( const Cube cube ) const [inline]

Test if this Cube is equal to another Cube.

The two Cubes are equal if both their Depth and Rectangle dimensions are equal.

Parameters:
cubeThe Cube to which this Cube is to be compared.
Returns:
true if the two Cubes are equal; false otherwise.

References Depth.

bool PIRL::Cube::operator!= ( const Cube cube ) const [inline]

Test if this Cube is not equal to another Cube.

The two Cubes are not equal if either their Depth or Rectangle dimensions are not equal.

Parameters:
cubeThe Cube to which this Cube is to be compared.
Returns:
true if the two Cubes are not equal; false otherwise.

References Depth.

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

Test for all zero dimension values.

Returns:
true if any dimension value is non-zero; false otherwise.

Reimplemented from PIRL::Rectangle.

References Depth.

bool PIRL::Cube::is_empty (  ) [inline]

Test for any zero dimension values.

Returns:
true if any dimension is zero; false otherwise.

Reimplemented from PIRL::Size_2D.

References Depth.

Cube & PIRL::Cube::operator+= ( int  amount )

Add an amount to the Cube Depth.

N.B.: If the Depth Dimensions_Type is unsigned (the default) and the amount is negative, the resulting Depth will not be less than zero.

Parameters:
amountAn integer amount to add to the Depth.
Returns:
This Cube with the amount applied.

Referenced by operator+=(), and operator-=().

Cube& PIRL::Cube::operator+= ( const Cube cube ) [inline]

Add another Cube's point coordinate offset, and depth and size amount.

Parameters:
cubeA Cube.
Returns:
This Cube with its point coordinate offset by the other Cube's point coordinate values, its Depth increased the other Cube's Depth, and the other Cube's size amount added to its size dimensions.

References Depth, and operator+=().

Cube& PIRL::Cube::operator-= ( int  amount ) [inline]

Subtract an amount from the Cube Depth.

N.B.: If the Depth Dimensions_Type is unsigned (the default) and the amount is positive, the resulting Depth will not be less than zero.

Parameters:
amountAn integer amount to subtract from the Depth.
Returns:
This Cube with the amount applied.

References operator+=().

Referenced by operator-=().

Cube& PIRL::Cube::operator-= ( const Cube cube ) [inline]

Subtract another Cube's point coordinate and depth offset and size amount.

Parameters:
cubeA Cube.
Returns:
This Cube with its point coordinate offset negatively by the other Cube's point coordinate values, its Depth offset negatively by the other Cube's Depth, and the other Cube's size amount subtracted from its size dimensions.

References Depth, and operator-=().

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

Multiply by a factor.

The new size values will be rounded to the nearest Dimensions_Types.

Parameters:
factorA factor by which to multiply the dimensions.
Returns:
This Cube with its dimension values changed.
Exceptions:
invalid_argumentIf the factor is negative and the size values Dimensions_Type are an unsigned type (as they are by default).

Reimplemented from PIRL::Rectangle.

References Depth, and PIRL::Round().

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

Divide by a factor.

The new size dimensions will be rounded to the nearest Dimensions_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 Dimensions_Type has an infinity value (determined by numeric_types) that is used, or its negative if the coordinate value is negative. Otherwise, if the Dimensions_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 dimensions.
Returns:
This Cube with its dimension values changed.
Exceptions:
invalid_argumentIf the factor is negative and the size values Dimensions_Type are an unsigned type (as they are by default).

Reimplemented from PIRL::Rectangle.

References PIRL::Rectangle::operator/=(), and PIRL::Round().

Cube & PIRL::Cube::operator&= ( const Cube cube )

Take the intersection with another Cube.

The intersection of the Depths of two Cubes is the minimum Depth; i.e. the two Cubes are assumed to be aligned at the zero X-Y plane.

Parameters:
cubeThe Cube to intersect with this Cube.
Returns:
This Cube with its position, size and depth set to the intersection with the other Cube. If the Cubes do not intersect this will result in an emtpy Cube (Width, Height and Depth zero) but the position will be unchanged.

References Depth, PIRL::Size_2D::is_empty(), and PIRL::Rectangle::operator&=().

Cube & PIRL::Cube::operator|= ( const Cube cube )

Take the union with another Cube.

The union of the Depths of two Cubes is the maximum Depth; i.e. the two Cubes are assumed to be aligned at the zero X-Y plane.

Parameters:
cubeThe Cube to unite with this Cube.
Returns:
This Cube with its position, size and depth set to the union - i.e. the bounding volume - with the other Cube.

References Depth, and PIRL::Rectangle::operator|=().


Member Data Documentation


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