Public Types | Public Member Functions | Private Attributes
datatypes::Box2D Class Reference

A rotated 2-dimensional box in the plane. More...

#include <Box2D.hpp>

Inheritance diagram for datatypes::Box2D:
Inheritance graph
[legend]

List of all members.

Public Types

typedef Point2D::value_type value_type
 The type of the stored x, y coordinates, and the rotation.

Public Member Functions

 Box2D ()
 Constructor for an all-zero Box2D.
 Box2D (const Point2D &center, const Point2D &size, value_type rotation=0.0)
 Constructor with specified center point, size, and rotation.
 Box2D (value_type x_center, value_type y_center, value_type x_size, value_type y_size, value_type rotation=0.0)
 Constructor with all values given.
virtual const UINT32 getUsedMemory () const
Accessor methods for information about this box
const Point2DgetCenter () const
 Returns the center point of this Box.
const Point2DgetSize () const
 Returns the size of this Box.
value_type getRotation () const
Polygon2D toPolygon () const
 Converts this Box2D to a closed polygon.
Box2D toBoundingBox () const
 Returns a Box in parallel to the coordinate system that bounds this box.
std::pair< value_type, value_typegetBoundingAngles () const
 Returns boundary angles for this box.
Box2D movedBy (const Point2D &centerMovement) const
 Returns a Box that is copied from this one but with its center point moved.
Setter methods for changing this box
void setCenter (const Point2D &p)
 Sets the center point of this Box2D.
void setCenter (value_type x, value_type y)
 Sets the center point of this Box2D.
void setSize (const Point2D &p)
 Sets the size of this Box. Must be non-negative.
void setSize (value_type x_length, value_type y_width)
 Sets the size of this Box2D. Must be non-negative.
void setRotation (value_type r)
 Sets the rotation angle of this Box in [radians], counter clock wise.
void moveBy (const Point2D &centerMovement)
 Move the center point of this box by the given point values.

Private Attributes

Point2D m_center
value_type m_rotation
Point2D m_size

Geometrical relations to other objects

bool containsPoint (const Point2D &point) const
 Returns true if the given Point2D is inside this box or on its outline.
Point2D::value_type distanceFromOutline (const Point2D &point) const
 Returns the distance from the outline of this Box2D to the given point.
Point2D::value_type distanceFromOutline (const std::vector< Point2D > &points) const
 Returns the mean distance from the outline of this Box2D to all points of the point vector.
Point2D::value_type distanceFromOutline (const std::vector< Point2D >::const_iterator &begin, const std::vector< Point2D >::const_iterator &end) const
 Returns the mean distance from the outline of this Box2D to all points of the given point iterator range.
std::string toString () const
static Box2D orientatedBox (value_type orientation_rad, const Polygon2D &poly)
 Returns an orientated bounding box for the given list of points.
static Box2D orientatedBox (value_type orientation_rad, const std::vector< Point2D > &points)
 Returns an orientated bounding box for the given list of points.
static Box2D orientatedBox (value_type orientation_rad, const std::vector< Point2D >::const_iterator &begin, const std::vector< Point2D >::const_iterator &end)
 Returns an orientated bounding box for the given list of points.
bool operator== (const Box2D &, const Box2D &)
bool operator!= (const Box2D &, const Box2D &)
void verifyNumericRanges ()

Detailed Description

A rotated 2-dimensional box in the plane.

This box (rectangle) is defined by its center point, its size in x- and y-direction, and its rotation.

The rotation denotes the rotation of this box' x-axis compared to the original x-axis. The size denotes the total length and width of this box in the box' coordinate system, i.e. the distance from the center point to each outline is half that size.

The size argument must be non-negative. The rotation argument must be in the range [-pi,pi], which can be obtained by using normalizeRadians().

Definition at line 34 of file Box2D.hpp.


Member Typedef Documentation

The type of the stored x, y coordinates, and the rotation.

Definition at line 38 of file Box2D.hpp.


Constructor & Destructor Documentation

Constructor for an all-zero Box2D.

Definition at line 23 of file Box2D.cpp.

datatypes::Box2D::Box2D ( const Point2D center,
const Point2D size,
value_type  rotation = 0.0 
)

Constructor with specified center point, size, and rotation.

Note:
The size components must be non-negative, otherwise an assertion will fail.
Parameters:
centerThe center point
sizeThe size of the box in the box' coordinate system. Must be non-negative.
rotationThe rotation of the box' coordinate system around its center point in [radians]. Must be in the interval [-pi,pi], which can be obtained by using normalizeRadians().

Definition at line 31 of file Box2D.cpp.

datatypes::Box2D::Box2D ( value_type  x_center,
value_type  y_center,
value_type  x_size,
value_type  y_size,
value_type  rotation = 0.0 
)

Constructor with all values given.

Constructor with all values given: x/y of center point, x/y of size (where the x coordinate of the size is in the same direction as the x axis of the coordinate system, rotated by the rotation argument; the y coordinate accordingly), and rotation.

Note:
The x_size and y_size must be non-negative.
Parameters:
x_centerX-coordinate of center point
y_centerY-coordinate of center point
x_sizeThe size of the box in X-direction in the box' coordinate system. Must be non-negative.
y_sizeThe size of the box in Y-direction in the box' coordinate system. Must be non-negative.
rotationThe rotation of the box' coordinate system around its center point in [radians]. Must be in the interval [-pi,pi], which can be obtained by using normalizeRadians().

Definition at line 44 of file Box2D.cpp.


Member Function Documentation

bool datatypes::Box2D::containsPoint ( const Point2D point) const

Returns true if the given Point2D is inside this box or on its outline.

(Note: This function is relatively cheap - it needs two sinus operations, four multiplications and a bunch of comparisons.)

Definition at line 173 of file Box2D.cpp.

Returns the distance from the outline of this Box2D to the given point.

This function calculates the minimum distance over the distances from the given point to each of the four outside lines of this Box2D.

Internally, this might be implemented using Polygon2D::distanceToPoint and Line2D::distanceFromLineSegment(), but maybe the implementation will be optimized to work in some other way.

Point2D::value_type datatypes::Box2D::distanceFromOutline ( const std::vector< Point2D > &  points) const

Returns the mean distance from the outline of this Box2D to all points of the point vector.

For each given point, this function calculates the minimum distance over the distances from the given point to each of the four outside lines of this Box2D and returns that minimum distance. The returned value is the mean value of all distances.

This is an overloaded version of distanceFromOutline(const Point2D&) for your convenience.

Point2D::value_type datatypes::Box2D::distanceFromOutline ( const std::vector< Point2D >::const_iterator &  begin,
const std::vector< Point2D >::const_iterator &  end 
) const

Returns the mean distance from the outline of this Box2D to all points of the given point iterator range.

For each given point, this function calculates the minimum distance over the distances from the given point to each of the four outside lines of this Box2D and returns that minimum distance. The returned value is the mean value of all distances.

This is an overloaded version of distanceFromOutline(const Point2D&) for your convenience.

Returns boundary angles for this box.

This function calculates a low and a high boundary angle for all edges of the given (rotated) Box2D. The returned FloatPair has the component "first" for the lower bounding angle, and "second" for the upper bounding angle.

(Note: This ordering is swapped compared to the scan point ordering!)

Definition at line 138 of file Box2D.cpp.

const Point2D& datatypes::Box2D::getCenter ( ) const [inline]

Returns the center point of this Box.

Definition at line 92 of file Box2D.hpp.

Returns the rotation angle of this Box2D in [radians], counter clock wise.

The rotation of the box' coordinate system around its center point. Must be in the interval [-pi,pi]

Definition at line 108 of file Box2D.hpp.

const Point2D& datatypes::Box2D::getSize ( ) const [inline]

Returns the size of this Box.

The returned size denotes the size of the box in x-direction Point2D::getX() and y-direction Point2D::getY(), where the x-direction is rotated against the original x-axis by getRotation().

Definition at line 101 of file Box2D.hpp.

virtual const UINT32 datatypes::Box2D::getUsedMemory ( ) const [inline, virtual]

Implements datatypes::BasicData.

Definition at line 85 of file Box2D.hpp.

void datatypes::Box2D::moveBy ( const Point2D centerMovement)

Move the center point of this box by the given point values.

Definition at line 79 of file Box2D.cpp.

Box2D datatypes::Box2D::movedBy ( const Point2D centerMovement) const

Returns a Box that is copied from this one but with its center point moved.

Definition at line 84 of file Box2D.cpp.

Box2D datatypes::Box2D::orientatedBox ( value_type  orientation_rad,
const Polygon2D poly 
) [static]

Returns an orientated bounding box for the given list of points.

Given a list of points and a fixed orientation, this function will calculate a bounding box for the points that has the given orientation.

Definition at line 379 of file Box2D.cpp.

Box2D datatypes::Box2D::orientatedBox ( value_type  orientation_rad,
const std::vector< Point2D > &  points 
) [static]

Returns an orientated bounding box for the given list of points.

Given a list of points and a fixed orientation, this function will calculate a bounding box for the points that has the given orientation.

This is an overloaded version of orientatedBox(const Polygon2D&) for your convenience.

Definition at line 393 of file Box2D.cpp.

Box2D datatypes::Box2D::orientatedBox ( value_type  orientation_rad,
const std::vector< Point2D >::const_iterator &  begin,
const std::vector< Point2D >::const_iterator &  end 
) [static]

Returns an orientated bounding box for the given list of points.

Given a list of points and a fixed orientation, this function will calculate a bounding box for the points that has the given orientation.

This is an overloaded version of orientatedBox(const Polygon2D&) for your convenience.

Definition at line 385 of file Box2D.cpp.

void datatypes::Box2D::setCenter ( const Point2D p) [inline]

Sets the center point of this Box2D.

Definition at line 148 of file Box2D.hpp.

void datatypes::Box2D::setCenter ( value_type  x,
value_type  y 
) [inline]

Sets the center point of this Box2D.

Definition at line 151 of file Box2D.hpp.

Sets the rotation angle of this Box in [radians], counter clock wise.

The rotation of the box' coordinate system around its center point. Must be in the interval [-pi,pi], which can be obtained by using normalizeRadians().

Definition at line 71 of file Box2D.cpp.

void datatypes::Box2D::setSize ( const Point2D p)

Sets the size of this Box. Must be non-negative.

Definition at line 58 of file Box2D.cpp.

void datatypes::Box2D::setSize ( value_type  x_length,
value_type  y_width 
)

Sets the size of this Box2D. Must be non-negative.

Definition at line 63 of file Box2D.cpp.

Returns a Box in parallel to the coordinate system that bounds this box.

This function calculates a bounding box to the given box, because the given one might be rotated into some other direction. In contrast to this, the returned box will have zero rotation and will be in parallel to the coordinate system.

Definition at line 115 of file Box2D.cpp.

Converts this Box2D to a closed polygon.

Converts this Box2D to a closed polygon with 5 points, where the last point is identical to the first one to make it closed.

Definition at line 89 of file Box2D.cpp.

std::string datatypes::Box2D::toString ( ) const

Definition at line 471 of file Box2D.cpp.

Definition at line 418 of file Box2D.cpp.


Friends And Related Function Documentation

bool operator!= ( const Box2D b1,
const Box2D b2 
) [friend]

Definition at line 277 of file Box2D.hpp.

bool operator== ( const Box2D b1,
const Box2D b2 
) [friend]

Definition at line 269 of file Box2D.hpp.


Member Data Documentation

Definition at line 40 of file Box2D.hpp.

Definition at line 42 of file Box2D.hpp.

Definition at line 41 of file Box2D.hpp.


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


libsick_ldmrs
Author(s): SICK AG , Martin Günther , Jochen Sprickerhof
autogenerated on Wed Jun 14 2017 04:04:50