next up previous contents index
Next: Rational Circles ( rat_circle Up: Basic Data Types for Previous: Rational Rays ( rat_ray

     
Straight Rational Lines ( rat_line )

Definition

An instance l of the data type rat$ \_$line is a directed straight line in the two-dimensional plane.

#include < LEDA/rat _line.h >

Creation

rat_line l(rat_point p, rat_point q)
    introduces a variable l of type rat_line. l is initialized to the line passing through points p and q directed form p to q.
Precondition: p! = q.
rat_line l(rat_segment s) introduces a variable l of type rat_line. l is initialized to the line supporting segment s.
Precondition: s is nontrivial.
rat_line l(rat_point p, rat_vector v)
    introduces a variable l of type rat_line. l is initialized to the line passing through points p and p + v.
Precondition: v is a nonzero vector.
rat_line l(rat_ray r) introduces a variable l of type rat_line. l is initialized to the line supporting ray r.
rat_line l introduces a variable l of type rat_line.
rat_line l(line l, int prec = rat_point::default_precision)
    introduces a variable l of type rat_line. l is initialized to the line obtained by approximating the two defining points of l.

Operations

line l.to_line() returns a floating point approximation of l.
rat_point l.point1() returns a point on l.
rat_point l.point2() returns a second point on l.
rat_segment l.seg() returns a segment on l.
bool l.is_vertical() decides whether l is vertical.
bool l.is_horizontal() decides whether l is horizontal.
bool l.intersection(rat_line g, rat_point& inter)
    returns true if l and g intersect. In case of intersection a common point is returned in inter.
bool l.intersection(rat_segment s, rat_point& inter)
    returns true if l and s intersect. In case of intersection a common point is returned in inter.
rat_line  l.translate(rational dx, rational dy)
    returns l translated by vector (dx, dy).
rat_line  l.translate(integer dx, integer dy, integer dw)
    returns l translated by vector (dx/dw, dy/dw).
rat_line  l.translate(rat_vector v) returns l translated by vector v.
Precondition: v.dim() = 2.
rat_line l + rat_vector v returns l translated by vector v.
rat_line l - rat_vector v returns l translated by vector - v.
rat_line  l.rotate90(rat_point q) returns l rotated about q by an angle of 90 degrees.
rat_line  l.reflect(rat_point p, rat_point q)
    returns l reflected across the straight line passing through p and q.
rat_line  l.reverse() returns l reversed.
rational l.sqr_dist(rat_point q) returns the square of the distance between l and q.
rat_segment l.perpendicular(rat_point p)
    returns the segment perpendicular to l with source p and target on l.
int  l.side_of(rat_point p) computes orientation(a, b, p), where a! = b and a and b appear in this order on line l.
bool l.contains(rat_point p) returns true if p lies on l.
bool l.clip(rat_point p, rat_point q, rat_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.
bool l == g returns true if the l and g are equal as oriented lines.
bool equal_as_sets(rat_line l, rat_line g)
    returns true if the l and g are equal as unoriented lines.

Non-Member Functions

int  orientation(rat_line l, rat_point p)
    computes orientation(a, b, p), where a! = b and a and b appear in this order on line l.
int  cmp_slopes(rat_line l1, rat_line l2)
    returns compare(slope(l1), slope(l2)).
rat_line  p_bisector(rat_point p, rat_point q)
    returns the perpendicular bisector of p and q. The bisector has p on its left.
Precondition: p! = q.


next up previous contents index
Next: Rational Circles ( rat_circle Up: Basic Data Types for Previous: Rational Rays ( rat_ray
LEDA research project
1999-04-23