Next: Real Points ( real_point Up: Basic Data Types for Previous: Rational Triangles ( rat_triangle   Contents   Index

# Iso-oriented Rational Rectangles ( rat_rectangle )

Definition

An instance r of the data type rectangle is an iso-oriented rectangle in the two-dimensional plane with rational coordinates.

#include < LEDA/geo/rat_rectangle.h >

Creation

 rat_rectangle r(const rat_point& p, const rat_point& q) introduces a variable r of type rat_rectangle. r is initialized to the rat_rectangle with diagonal corners p and q rat_rectangle r(const rat_point& p, rational w, rational h) introduces a variable r of type rat_rectangle. r is initialized to the rat_rectangle with lower left corner p, width w and height h. rat_rectangle r(rational x1, rational y1, rational x2, rational y2) introduces a variable r of type rat_rectangle. r is initialized to the rat_rectangle with diagonal corners (x1,y1) and (x2,y2). rat_rectangle r(const rectangle& r, int prec = rat_point::default_precision) introduces a variable r of type rat_rectangle. r is initialized to the rectangle obtained by approximating the defining points of r .

Operations

 rectangle r.to_float() returns a floating point approximation of R . void r.normalize() simplifies the homogenous representation by calling p.normalize() for every vertex of r. rat_point r.upper_left() returns the upper left corner. rat_point r.upper_right() returns the upper right corner. rat_point r.lower_left() returns the lower left corner. rat_point r.lower_right() returns the lower right corner. rat_point r.center() returns the center of r. list< rat_point> r.vertices() returns the vertices of r in counterclockwise order starting from the lower left point. rational r.xmin() returns the minimal x-coordinate of r. rational r.xmax() returns the maximal x-coordinate of r. rational r.ymin() returns the minimal y-coordinate of r. rational r.ymax() returns the maximal y-coordinate of r. rational r.width() returns the width of r. rational r.height() returns the height of r. bool r.is_degenerate() returns true, if r degenerates to a segment or point (the 4 corners are collinear), false otherwise. bool r.is_point() returns true, if r degenerates to a point. bool r.is_segment() returns true, if r degenerates to a segment. int r.cs_code(const rat_point& p) returns the code for Cohen-Sutherland algorithm. bool r.inside(const rat_point& p) returns true, if p is inside of r, false otherwise. bool r.inside_or_contains(const rat_point& p) returns true, if p is inside of r or on the border, false otherwise. bool r.outside(const rat_point& p) returns true, if p is outside of r, false otherwise. bool r.contains(const rat_point& p) returns true, if p is on the border of r, false otherwise. region_kind r.region_of(const rat_point& p) returns BOUNDED_REGION if p lies in the bounded region of r, returns ON_REGION if p lies on r, and returns UNBOUNDED_REGION if p lies in the unbounded region. rat_rectangle r.include(const rat_point& p) returns a new rat_rectangle that includes the points of r and p. rat_rectangle r.include(const rat_rectangle& r2) returns a new rat_rectangle that includes the points of r and r2. rat_rectangle r.translate(rational dx, rational dy) returns r translated by (dx,dy). rat_rectangle r.translate(const rat_vector& v) returns r translated by v. rat_rectangle r + const rat_vector& v returns r translated by v. rat_rectangle r - const rat_vector& v returns r translated by vector -v. rat_point r[int i] returns the i-th vertex of r. Precondition: (0 0 the rotation is counter-clockwise otherwise it is clockwise. rat_rectangle r.rotate90(int i=1) returns r rotated by an angle of i x 90 degrees about the origin. rat_rectangle r.reflect(const rat_point& p) returns r reflected across p. bool r.clip(const rat_segment& t, rat_segment& inter) clips t on r and returns the result in inter. bool r.clip(const rat_line& l, rat_segment& inter) clips l on r and returns the result in inter. bool r.clip(const rat_ray& ry, rat_segment& inter) clips ry on r and returns the result in inter. bool r.difference(const rat_rectangle& q, list< rat_rectangle> & L) returns true iff the difference of r and q is not empty, and false otherwise. The difference L is returned as a partition into rectangles. list< rat_point> r.intersection(const rat_segment& s) returns r s . list< rat_point> r.intersection(const rat_line& l) returns r l . list< rat_rectangle> r.intersection(const rat_rectangle& s) returns r s . bool r.do_intersect(const rat_rectangle& b) returns true iff r and b intersect, false otherwise. rational r.area() returns the area of r.

Next: Real Points ( real_point Up: Basic Data Types for Previous: Rational Triangles ( rat_triangle   Contents   Index
Christian Uhrig 2017-04-07