Definition
An instance r of the data type rectangle is an iso-oriented rectangle in the two-dimensional plane.
#include < LEDA/rectangle.h >
Creation
| rectangle | r(point p, point q) | introduces a variable r of type rectangle. r is initialized to the rectangle with diagonal corners p and q |
| rectangle | r(point p, double w, double h) | |
| introduces a variable r of type rectangle. r is initialized to the rectangle with lower left corner p, width w and height h. | ||
| rectangle | r(double x1, double y1, double x2, double y2) | |
| introduces a variable r of type rectangle. r is initialized to the rectangle with diagonal corners (x1,y1) and (x2,y2). | ||
Operations
| point | r.upper_left() | returns the upper left corner. |
| point | r.upper_right() | returns the upper right corner. |
| point | r.lower_left() | returns the lower left corner. |
| point | r.lower_right() | returns the lower right corner. |
| point | r.center() | returns the center of r. |
| list<point> | r.vertices() | returns the vertices of r in counterclockwise order starting from the lower left point. |
| double | r.xmin() | returns the minimal x-coordinate of r. |
| double | r.xmax() | returns the maximal x-coordinate of r. |
| double | r.ymin() | returns the minimal y-coordinate of r. |
| double | r.ymax() | returns the maximal y-coordinate of r. |
| double | r.width() | returns the width of r. |
| double | 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(point p) | returns the code for Cohen-Sutherland algorithm. |
| bool | r.inside(point p) | returns true, if p is inside of r, false otherwise. |
| bool | r.outside(point p) | returns true, if p is outside of r, false otherwise. |
| bool | r.inside_or_contains(point p) | |
| returns true, if p is inside of r or on the border, false otherwise. | ||
| bool | r.contains(point p) | returns true, if p is on the border of r, false otherwise. |
| region_kind | r.region_of(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. |
| rectangle | r.include(point p) | returns a new rectangle that includes the points of r and p. |
| rectangle | r.include(rectangle r2) | returns a new rectangle that includes the points of r and r2. |
| rectangle | r.translate(double dx, double dy) | |
| returns a new rectangle that is the translation of r by (dx,dy). | ||
| rectangle | r.translate(vector v) | returns a new rectangle that is the translation of r by v. |
| rectangle | r + vector v | returns r translated by v. |
| rectangle | r - vector v | returns r translated by -v. |
| point | r[int i] | returns the i-th vertex of r. Precondition: (0<i<5). |
| rectangle | r.rotate90(point p, int i=1) | |
| returns r rotated about p by an angle of i x 90 degrees. If i > 0 the rotation is counter-clockwise otherwise it is clockwise. | ||
| rectangle | r.rotate90(int i=1) | returns r rotated by an angle of i x 90 degrees about the origin. |
| rectangle | r.reflect(point p) | returns r reflected across p . |
| list<point> | r.intersection(segment s) | returns r |
| bool | r.clip(segment t, segment& inter) | |
| clips t on r and returns the result in inter. | ||
| bool | r.clip(line l, segment& inter) | |
| clips l on r and returns the result in inter. | ||
| bool | r.clip(ray ry, segment& inter) | |
| clips ry on r and returns the result in inter. | ||
| bool | r.difference(rectangle q, list<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<point> | r.intersection(line l) | returns r |
| list<rectangle> | r.intersection(rectangle r) | |
| returns r |
||
| bool | r.do_intersect(rectangle b) | |
| returns true iff r and b intersect, false otherwise. | ||
| double | r.area() | returns the area of r. |
© Copyright 1995-2002, Algorithmic Solutions Software GmbH. All rights reserved.
2002-10-16