april  1.0.0
...
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ABOX2D Struct Reference

Represents a rectangle that is aligned with the axis. More...

#include <abox2d.h>

+ Inheritance diagram for ABOX2D:

Public Member Functions

void reset (void)
 bring the internal variables to their ground state
bool operator== (const ABOX2D &other) const
 compares two rectangles
bool operator!= (const ABOX2D &other) const
 compares two points (their coorsinates)
void operator+= (const ABOX2D &other)
 computes the bounding rectangle for the two input boxes
void operator-= (const ABOX2D &other)
 computes the rectangle that is common to the two input boxes
COORDV width (void) const
 width (side on the x axis)
COORDV height (void) const
 height (side on the y axis)
bool isDegenerate (void) const
 tell if this box is degenerate or not
COORDV diagonal (void) const
 lenght of diagonal
void unite (const ABOX2D &first, const ABOX2D &second)
 set this rectangle to the union of two rectangles
void unite (const ABOX2D &other)
 set this rectangle to the union of this and other rectangle
bool contains (const P2D &other) const
 tell if the box contains a point
bool contains (const ABOX2D &other) const
 tell if the box contains another box
bool intersect (const ABOX2D &first, const ABOX2D &second)
 set this rectangle to the intersection of two rectangles
bool intersect (const ABOX2D &other)
 set this rectangle to the intersection of this and other rectangle
bool isNormalised (void) const
 tell if the rectangle is normalised (x1<x2, y1<y2)
void normalise (void)
 normalise the rectangle (x1<x2, y1<y2)
void offset (COORDV dist)
 extend or contract this box by given ammount
void offset (COORDV dist, ABOX2D &out) const
 extend or contract the box by given ammount
void translate (COORDV dx, COORDV dy)
 move the item by this ammount relative to current position
bool visibleIn (const ABOX2D &other) const
 tell if the segment is "visible" inside given shape
COORDV area (void)
 the area of this thing
void center (P2D &c)
 the center point of this one

Public Attributes

union {
   COORDV   pts_ [4]
 coordinates in an array of 4 values: left, bottom, right, top
   struct {
      COORDV   left_
 X1 component.
      COORDV   bottom_
 Y1 component.
      COORDV   right_
 X2 component.
      COORDV   top_
 Y2 component.
   } 
   struct {
      P2D   bottom_left_
 first point
      P2D   top_right_
 second point
   } 
}; 

Detailed Description

Represents a rectangle that is aligned with the axis.

The line isDegenerate() if the two points that define it are identical ( P2D::isEqual() == true )

Member Function Documentation

bool ABOX2D::contains ( const P2D other) const

tell if the box contains a point

If the point is directly over left or bottom margin the method returns true; if the point is directly over right or top margin the method returns false.

bool ABOX2D::contains ( const ABOX2D other) const

tell if the box contains another box

Only returns true if the other box is fully contained by this box. Identical rectangles return true with this method.

bool ABOX2D::intersect ( const ABOX2D first,
const ABOX2D second 
)

set this rectangle to the intersection of two rectangles

Returns
true if the rectangles intersect and false if they do not
bool ABOX2D::intersect ( const ABOX2D other)

set this rectangle to the intersection of this and other rectangle

Returns
true if the rectangles intersect and false if they do not
bool ABOX2D::isDegenerate ( void  ) const
inline

tell if this box is degenerate or not

The box is degenerate if any of the width() or height() are zero or negative

void ABOX2D::offset ( COORDV  dist)

extend or contract this box by given ammount

A positive value will expand the box; a negative value will shrink it

void ABOX2D::offset ( COORDV  dist,
ABOX2D out 
) const

extend or contract the box by given ammount

A positive value will expand the box; a negative value will shrink it

bool ABOX2D::operator== ( const ABOX2D other) const
inline

compares two rectangles

Two rectangles are the same if their coordinates are the same

bool ABOX2D::visibleIn ( const ABOX2D other) const

tell if the segment is "visible" inside given shape

"visible" is satisfied if the shape intersects or contains the segment.


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