iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nrt::RotatedRectangle< T > Class Template Reference

#include <nrt/Core/Geometry/RotatedRectangle.H>

template<class T>
class nrt::RotatedRectangle< T >

A 2D rotated rectangle containing a center point, dimensions, and an angle.

Examples:
tests/test-Geometry.C.

Definition at line 48 of file RotatedRectangle.H.

Public Member Functions

 RotatedRectangle ()=default
 Default constructor.
 
 RotatedRectangle (Point2D< T > const &center, Dims< T > const &dims, double const &angle)
 Construct a RotatedRectangle from a center point, dimensions, and an angle (in radians)
 
 RotatedRectangle (RotatedRectangle< T > const &other)=default
 Copy Constructor.
 
 RotatedRectangle (RotatedRectangle< T > &&other)=default
 Move constructor.
 
template<class U >
 RotatedRectangle (RotatedRectangle< U > const &other)
 Copy from a RotatedRectangle of a different datatype. More...
 
RotatedRectangle< T > & operator= (RotatedRectangle< T > const &other)=default
 Assignment.
 
RotatedRectangle< T > & operator= (RotatedRectangle< T > &&other)=default
 Move assignment.
 
Point2D< T > center () const
 Get the center point.
 
Dims< T > dims () const
 Get the dimensions.
 
double angle () const
 Get the angle (in radians)
 
std::vector< Point2D< T > > vertices () const
 Compute the four vertices.
 

Static Public Member Functions

static RotatedRectangle< T > minEnclosingRectangle (Polygon< T > const &convexPoly)
 Find the RotatedRectangle with the minimum area which encloses a convex Polygon. More...
 

Friends

class cereal::access
 

Related Functions

(Note that these are not member functions.)

template<class T >
std::ostream & operator<< (std::ostream &out, RotatedRectangle< T > const &r)
 Human-readable output to a stream: outputs [Center: xxx, Dims: xxx, Amgle: xxx]. More...
 
template<class T >
RotatedRectangle< T > scale (RotatedRectangle< T > const &src, double const factor)
 Return a scaled version of the source object. More...
 
template<class T >
RotatedRectangle< T > rotate (RotatedRectangle< T > const &src, double const angle)
 Return a rotated version of the source object, about its center by a given angle in radians. More...
 
template<class T >
RotatedRectangle< T > rotateAbout (RotatedRectangle< T > const &src, Point2D< T > const &p, double const angle)
 Return a rotated version of the source object, about the given point and by a given angle in radians. More...
 
template<class T >
bool operator== (RotatedRectangle< T > const &lhs, RotatedRectangle< T > const &rhs)
 Operator overload for RotatedRectangle<T> == RotatedRectangle<T> More...
 
template<class T >
bool operator!= (RotatedRectangle< T > const &lhs, RotatedRectangle< T > const &rhs)
 Operator overload for RotatedRectangle<T> != RotatedRectangle<T> More...
 
template<class T >
RotatedRectangle< T > operator+ (RotatedRectangle< T > const &lhs, Point2D< T > const &rhs)
 Operator overload for RotatedRectangle<T> + Point2D<T> More...
 
template<class T >
RotatedRectangle< T > operator+ (Point2D< T > const &lhs, RotatedRectangle< T > const &rhs)
 Operator overload for Point2D<T> + RotatedRectangle<T> More...
 
template<class T >
RotatedRectangle< T > operator- (RotatedRectangle< T > const &lhs, nrt::Point2D< T > const &rhs)
 Operator overload for RotatedRectangle<T> - Point2D<T> More...
 
template<class T >
RotatedRectangle< T > operator- (Point2D< T > const &lhs, RotatedRectangle< T > const &rhs)
 Operator overload for Point2D<T> - RotatedRectangle<T> More...
 
template<class T >
RotatedRectangle< T > operator* (RotatedRectangle< T > const &lhs, double const rhs)
 Operator overload for RotatedRectangle<T> * double. More...
 
template<class T >
RotatedRectangle< T > operator* (double const lhs, RotatedRectangle< T > const &rhs)
 Operator overload for double * RotatedRectangle<T> More...
 
template<class T >
RotatedRectangle< T > operator/ (RotatedRectangle< T > const &lhs, double const rhs)
 Operator overload for RotatedRectangle<T> / double. More...
 
template<class T >
RotatedRectangle< T > & operator*= (RotatedRectangle< T > &lhs, double const rhs)
 Operator overload for RotatedRectangle<T> *= double. More...
 
template<class T >
RotatedRectangle< T > & operator/= (RotatedRectangle< T > &lhs, double const rhs)
 Operator overload for RotatedRectangle<T> /= double. More...
 
template<class T >
RotatedRectangle< T > & operator+= (RotatedRectangle< T > &lhs, Point2D< T > const &rhs)
 Operator overload for RotatedRectangle<T> += Point2D<T> More...
 
template<class T >
RotatedRectangle< T > & operator-= (RotatedRectangle< T > &lhs, Point2D< T > const &rhs)
 Operator overload for RotatedRectangle<T> -= Point2D<T> More...
 

Constructor & Destructor Documentation

template<class T >
template<class U >
nrt::RotatedRectangle< T >::RotatedRectangle ( RotatedRectangle< U > const &  other)
explicit

Copy from a RotatedRectangle of a different datatype.

This will internally use nrt::clamped_convert<T,U> on the center and dims

Definition at line 43 of file RotatedRectangleImpl.H.

Member Function Documentation

template<class T >
nrt::RotatedRectangle< T > nrt::RotatedRectangle< T >::minEnclosingRectangle ( Polygon< T > const &  convexPoly)
static

Find the RotatedRectangle with the minimum area which encloses a convex Polygon.

This method uses the algorithm outlined in "A Linear Time Algorithm for the Minimum Area Rectangle Enclosing a Convex Polygon" by Arnon & Gieselmann, 1983. The algorithm works by using the "Rotating Calipers" method, which exploits a proof showing that the minimum area enclosing rectangle will have one edge which meets an edge of the Polygon.

The returned rectangle will have an angle between 0-pi, and it's width will always be at least as large as it's height.

Note
The given Polygon must be convex, otherwise the calculated RotatedRectangle will be incorrect.
Examples:
tests/test-Geometry.C.

Definition at line 150 of file RotatedRectangleImpl.H.

References nrt::Dims< T >::height(), nrt::Line< T >::intersectInfinite(), nrt::rotate(), nrt::Polygon< T >::vertices(), nrt::Dims< T >::width(), nrt::Point2D< T >::x(), and nrt::Point2D< T >::y().

Friends And Related Function Documentation

template<class T >
std::ostream & operator<< ( std::ostream &  out,
RotatedRectangle< T > const &  r 
)
related

Human-readable output to a stream: outputs [Center: xxx, Dims: xxx, Amgle: xxx].

template<class T >
RotatedRectangle< T > scale ( RotatedRectangle< T > const &  src,
double const  factor 
)
related

Return a scaled version of the source object.

Note
This does not have the same effect as the multiplication or division operators, which scale everything, while here we only scale the object size without scaling its center coordinates.
template<class T >
RotatedRectangle< T > rotate ( RotatedRectangle< T > const &  src,
double const  angle 
)
related

Return a rotated version of the source object, about its center by a given angle in radians.

template<class T >
RotatedRectangle< T > rotateAbout ( RotatedRectangle< T > const &  src,
Point2D< T > const &  p,
double const  angle 
)
related

Return a rotated version of the source object, about the given point and by a given angle in radians.

template<class T >
bool operator== ( RotatedRectangle< T > const &  lhs,
RotatedRectangle< T > const &  rhs 
)
related

Operator overload for RotatedRectangle<T> == RotatedRectangle<T>

template<class T >
bool operator!= ( RotatedRectangle< T > const &  lhs,
RotatedRectangle< T > const &  rhs 
)
related

Operator overload for RotatedRectangle<T> != RotatedRectangle<T>

template<class T >
RotatedRectangle< T > operator+ ( RotatedRectangle< T > const &  lhs,
Point2D< T > const &  rhs 
)
related

Operator overload for RotatedRectangle<T> + Point2D<T>

template<class T >
RotatedRectangle< T > operator+ ( Point2D< T > const &  lhs,
RotatedRectangle< T > const &  rhs 
)
related

Operator overload for Point2D<T> + RotatedRectangle<T>

template<class T >
RotatedRectangle< T > operator- ( RotatedRectangle< T > const &  lhs,
nrt::Point2D< T > const &  rhs 
)
related

Operator overload for RotatedRectangle<T> - Point2D<T>

template<class T >
RotatedRectangle< T > operator- ( Point2D< T > const &  lhs,
RotatedRectangle< T > const &  rhs 
)
related

Operator overload for Point2D<T> - RotatedRectangle<T>

template<class T >
RotatedRectangle< T > operator* ( RotatedRectangle< T > const &  lhs,
double const  rhs 
)
related

Operator overload for RotatedRectangle<T> * double.

template<class T >
RotatedRectangle< T > operator* ( double const  lhs,
RotatedRectangle< T > const &  rhs 
)
related

Operator overload for double * RotatedRectangle<T>

template<class T >
RotatedRectangle< T > operator/ ( RotatedRectangle< T > const &  lhs,
double const  rhs 
)
related

Operator overload for RotatedRectangle<T> / double.

template<class T >
RotatedRectangle< T > & operator*= ( RotatedRectangle< T > &  lhs,
double const  rhs 
)
related

Operator overload for RotatedRectangle<T> *= double.

template<class T >
RotatedRectangle< T > & operator/= ( RotatedRectangle< T > &  lhs,
double const  rhs 
)
related

Operator overload for RotatedRectangle<T> /= double.

template<class T >
RotatedRectangle< T > & operator+= ( RotatedRectangle< T > &  lhs,
Point2D< T > const &  rhs 
)
related

Operator overload for RotatedRectangle<T> += Point2D<T>

template<class T >
RotatedRectangle< T > & operator-= ( RotatedRectangle< T > &  lhs,
Point2D< T > const &  rhs 
)
related

Operator overload for RotatedRectangle<T> -= Point2D<T>


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