libidx
|
A templated rectange class with default type 'uint'. More...
#include <geometry.h>
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. | |
T | h1 () const |
T | 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. | |
T | area () const |
Return area of rectangle (i.e. height * width). | |
T | intersection_area (const rect< T > &r) const |
Return area of intersection between this rectangle and r. | |
T | 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 | |
T | h0 |
T | w0 |
T | height |
T | width |
A templated rectange class with default type 'uint'.
Return the height distance between this and r's centers height, over the height of this rect.
Return the width distance between this and r's centers width, over the width of this rect.
T ebl::rect< T >::h1 | ( | ) | const |
Return bottom coordinate, i.e. h0 + height.
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.
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.
Returns the overlap ratio with the smallest of the 2 rectangles, i.e. intersection / min(this.area, r.area).
Returns true if the ratio of the overlapping area over the smallest rectangle is more than the minarea ratio.
minarea | Ratio of minimum area overlap required to declare overlap. |
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.
hmin | Minimum height overlap ratio required to declare overlap. |
wmin | Minimum width overlap ratio required to declare overlap. |
Returns the ratio of the intersection of this rect and r over this rect's area.
void ebl::rect< T >::rotate | ( | float | degree_angle | ) |
Rotates the rectangle clockwise by 'alpha', with the center of the rect as center of rotation.
degree_angle | The rotation angle in degrees. |
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.
void ebl::rect< T >::scale_height | ( | float | woverh_ratio | ) |
Scale height to width * 'woverh_ratio', and shift h0 accordingly to keep the same center.
void ebl::rect< T >::scale_width | ( | float | woverh_ratio | ) |
Scale width to height * 'woverh_ratio', and shift w0 accordingly to keep the same center.
Return area of union between this rectangle and r, i.e. this.area + r.area - intersection