next up previous contents index
Next: Straight Rational Lines ( Up: Basic Data Types for Previous: Rational Segments ( rat_segment

     
Rational Rays ( rat_ray )

Definition

An instance r of the data type rat$ \_$ray is a directed straight ray defined by two points with rational coordinates in the two-dimensional plane.

#include < LEDA/rat _ray.h >

Creation

rat_ray r(rat_point p, rat_point q)
    introduces a variable r of type rat_ray. r is initialized to the ray starting at point p and passing through point q.
Precondition: p! = q.
rat_ray r(rat_segment s) introduces a variable r of type rat_ray. r is initialized to the (rat$ \_$ray(s.source(), s.target()).
Precondition: s is nontrivial.
rat_ray r introduces a variable r of type rat_ray.
rat_ray r(ray r, int prec = rat_point::default_precision)
    introduces a variable r of type rat_ray. r is initialized to the ray obtained by approximating the two defining points of r.

Operations

ray r.to_ray() returns a floating point approximation of r.
rat_point r.source() returns the source of r.
rat_point r.point1() returns the source of r.
rat_point r.point2() returns a point on r different from r.source().
bool r.is_vertical() returns true iff r is vertical.
bool r.is_horizontal() returns true iff r is horizontal.
bool r.intersection(rat_ray s, rat_point& inter)
    returns true if r and s intersect. If so, a point of intersection is returned in inter.
bool r.intersection(rat_segment s, rat_point& inter)
    returns true if r and s intersect. If so, a point of intersection is returned in inter.
rat_ray  r.translate(rational dx, rational dy)
    returns r translated by vector (dx, dy).
rat_ray  r.translate(integer dx, integer dy, integer dw)
    returns r translated by vector (dx/dw, dy/dw).
rat_ray  r.translate(rat_vector v) returns r + v, i.e., r translated by vector v.
Precondition: v.dim() = 2.
rat_ray r + rat_vector v returns r translated by vector v.
rat_ray r - rat_vector v returns r translated by vector - v.
rat_ray  r.rotate90(rat_point q) returns r rotated about q by an angle of 90 degrees.
rat_ray  r.reflect(rat_point p, rat_point q)
    returns r reflected across the straight line passing through p and q.
Precondition: p! = q.
rat_ray  r.reflect(rat_point p) returns r reflected across point p.
rat_ray  r.reverse() returns r reversed.
bool r.contains(rat_point p) decides whether r contains p.
bool r.contains(rat_segment s) decides whether r contains s.

Non-Member Functions

int  orientation(rat_ray r, rat_point p)
    computes orientation(a, b, p), where a! = b and a and b appear in this order on ray r.
int  cmp_slopes(rat_ray r1, rat_ray r2)
    returns compare(slope(r1), slope(r2)).


next up previous contents index
Next: Straight Rational Lines ( Up: Basic Data Types for Previous: Rational Segments ( rat_segment
LEDA research project
1999-04-23