Definition
An instance l of the data type line is a directed straight line in the two-dimensional plane. The angle between a right oriented horizontal line and l is called the direction of l.
#include < LEDA/line.h >
Types
line::coord_type | the coordinate type (double). |
line::point_type | the point type (point). |
Creation
line | l(point p, point q) | introduces a variable l of type line. l is initialized to the line passing through points p and q directed form p to q. |
line | l(segment s) | introduces a variable l of type line. l is initialized to the line supporting segment s. |
line | l(ray r) | introduces a variable l of type line. l is initialized to the line supporting ray r. |
line | l(point p, vector v) | introduces a variable l of type line. l is initialized to the line passing through points p and p + v. |
line | l(point p, double alpha) | introduces a variable l of type line. l is initialized to the line passing through point p with direction alpha. |
line | l | introduces a variable l of type line. l is initialized to the line passing through the origin with direction 0. |
Operations
point | l.point1() | returns a point on l. |
point | l.point2() | returns a second point on l. |
segment | l.seg() | returns a segment on l. |
double | l.angle(line g) | returns the angle between l and g, i.e., g.direction() - l.direction(). |
double | l.direction() | returns the direction of l. |
double | l.angle() | returns l.direction(). |
bool | l.is_vertical() | returns true iff l is vertical. |
bool | l.is_horizontal() | returns true iff l is horizontal. |
double | l.sqr_dist(point q) | returns the square of the distance between l and q. |
double | l.distance(point q) | returns the distance between l and q. |
double | l.slope() | returns the slope of l.
Precondition l is not vertical. |
double | l.y_proj(double x) | returns p.ycoord(), where p l with p.xcoord() = x.
Precondition l is not vertical. |
double | l.x_proj(double y) | returns p.xcoord(), where p l with p.ycoord() = y.
Precondition l is not horizontal. |
double | l.y_abs() | returns the y-abscissa of l (l.y_proj(0)).
Precondition l is not vertical. |
bool | l.intersection(line g, point& p) | |
if l and g intersect in a single point this point is assigned to p and the result is true, otherwise the result is false. | ||
bool | l.intersection(segment s, point& inter) | |
if l and s intersect in a single point this point is assigned to p and the result is true, otherwise the result is false. | ||
line | l.translate_by_angle(double a, double d) | |
returns l translated in direction a by distance d. | ||
line | l.translate(double dx, double dy) | |
returns l translated by vector (dx, dy). | ||
line | l.translate(vector v) | returns l translated by vector v.
Precondition v.dim() = 2. |
line | l + vector v | returns l translated by vector v. |
line | l - vector v | returns l translated by vector - v. |
line | l.rotate(point q, double a) | |
returns l rotated about point q by angle a. | ||
line | l.rotate(double a) | returns l.rotate( point(0, 0), a). |
line | l.rotate90(point q) | returns l rotated about q by angle of 90 degrees. |
line | l.reflect(point p, point q) | |
returns l reflected across the straight line passing through p and q. | ||
line | l.reverse() | returns l reversed. |
segment | l.perpendicular(point p) | returns the segment perpendicular to l with source p. and target on l. |
point | l.dual() | returns the point dual to l.
/precond l is not vertical. |
bool | l.contains(point p) | returns true if p lies on l. |
bool | l.clip(point p, point q, segment& s) | |
clips l at the rectangle R defined by p and q. Returns true if the intersection of R and l is non-empty and returns false otherwise. If the intersection is non-empty the intersection is assigned to s; It is guaranteed that the source node of s is no larger than its target node. |
Non-Member Functions
int | orientation(line l, point p) | |
computes orientation(a, b, p), where a b and a and b appear in this order on line l. | ||
int | cmp_slopes(line l1, line l2) | |
returns compare(slope(l1), slope(l2)). |