libidx
ebl::rect< T > Class Template Reference

A templated rectange class with default type 'uint'. More...

#include <geometry.h>

List of all members.

Public Member Functions

 rect (T h0, T w0, T height, T width)
 A rectangle with offset (h0, w0) and size (height, width).
 rect ()
 Empty constructor. All values are initialized 0.
 rect (const rect< T > &r)
 Values are initialized with 'r' values.
virtual ~rect ()
 Destructor.
h1 () const
w1 () const
 Return right coordinate, i.e. w0 + width.
float hcenter () const
 Return center's height, i.e. h0 + height / 2.
float wcenter () const
 Return center's width, i.e. h0 + height / 2.
area () const
 Return area of rectangle (i.e. height * width).
intersection_area (const rect< T > &r) const
 Return area of intersection between this rectangle and r.
union_area (const rect< T > &r) const
float match (const rect< T > &r) const
float min_match (const rect< T > &r)
float center_distance (const rect< T > &r) const
 Return the euclidean distance between this and r's centers.
float center_hdistance (const rect< T > &r) const
float center_wdistance (const rect< T > &r) const
bool overlap (const rect< T > &r) const
 return true if current rectangle overlaps with r.
float overlap_ratio (const rect< T > &r) const
bool min_overlap (const rect< T > &r, float hmin, float wmin) const
float min_overlap (const rect< T > &r) const
bool min_overlap (const rect< T > &r, float minarea) const
bool is_within (const rect< T > &r)
 return true current rectangle is entirely contained in r.
void shift (T h, T w)
 Shift rectangle's origin by h and w.
void scale_centered (float sh, float sw)
void scale_width (float woverh_ratio)
void scale_height (float woverh_ratio)
float radius ()
 Returns the radius of the circle passing by each corner of this rect.
void rotate (float degree_angle)
rect< T > operator/ (double d)
 Divide all components (h0, w0, height, width) of this rect by 'd'.
rect< T > operator* (double d)
 Multiply all components (h0, w0, height, width) of this rect by 'd'.
template<typename T2 >
rect< T > operator= (rect< T2 > &r2)
 Assign 'r2' to this rect.
void rotate_point (float alpha, float &h, float &w)
 Rotate a point (h,w) by alpha radians.

Public Attributes

h0
w0
height
width

Detailed Description

template<typename T = uint>
class ebl::rect< T >

A templated rectange class with default type 'uint'.


Member Function Documentation

template<typename T >
float ebl::rect< T >::center_hdistance ( const rect< T > &  r) const

Return the height distance between this and r's centers height, over the height of this rect.

template<typename T >
float ebl::rect< T >::center_wdistance ( const rect< T > &  r) const

Return the width distance between this and r's centers width, over the width of this rect.

template<typename T >
T ebl::rect< T >::h1 ( ) const

Return bottom coordinate, i.e. h0 + height.

template<typename T >
float ebl::rect< T >::match ( const rect< T > &  r) const

Return how much this rect matches with r, between 0.0 and 1.0, i.e. intersection / union, 0.0 means the 2 rectangles do not overlap at all whereas 1.0 means they are identical.

template<typename T >
float ebl::rect< T >::min_match ( const rect< T > &  r)

Return how much this rect matches with r, between 0.0 and 1.0, i.e. intersection / min(area, r.area), 0.0 means the 2 rectangles do not overlap at all whereas 1.0 means they are identical.

template<typename T >
float ebl::rect< T >::min_overlap ( const rect< T > &  r) const

Returns the overlap ratio with the smallest of the 2 rectangles, i.e. intersection / min(this.area, r.area).

template<typename T >
bool ebl::rect< T >::min_overlap ( const rect< T > &  r,
float  minarea 
) const

Returns true if the ratio of the overlapping area over the smallest rectangle is more than the minarea ratio.

Parameters:
minareaRatio of minimum area overlap required to declare overlap.
template<typename T >
bool ebl::rect< T >::min_overlap ( const rect< T > &  r,
float  hmin,
float  wmin 
) const

Returns true if current rectangle overlaps with r more than authorized ratios hmin and wmin. The ratio is computed with overlap / smallest rectangle.

Parameters:
hminMinimum height overlap ratio required to declare overlap.
wminMinimum width overlap ratio required to declare overlap.
template<typename T >
float ebl::rect< T >::overlap_ratio ( const rect< T > &  r) const

Returns the ratio of the intersection of this rect and r over this rect's area.

template<typename T >
void ebl::rect< T >::rotate ( float  degree_angle)

Rotates the rectangle clockwise by 'alpha', with the center of the rect as center of rotation.

Parameters:
degree_angleThe rotation angle in degrees.
template<typename T >
void ebl::rect< T >::scale_centered ( float  sh,
float  sw 
)

Scale height and width while keeping the same center, as opposed to operator* that scales height and width but also h0 and w0, thus changing the original center.

template<typename T >
void ebl::rect< T >::scale_height ( float  woverh_ratio)

Scale height to width * 'woverh_ratio', and shift h0 accordingly to keep the same center.

template<typename T >
void ebl::rect< T >::scale_width ( float  woverh_ratio)

Scale width to height * 'woverh_ratio', and shift w0 accordingly to keep the same center.

template<typename T >
T ebl::rect< T >::union_area ( const rect< T > &  r) const

Return area of union between this rectangle and r, i.e. this.area + r.area - intersection


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