Next: Straight Rational Lines ( Up: Basic Data Types for Previous: Rational Segments ( rat_segment   Contents   Index

# Rational Rays ( rat_ray )

Definition

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

#include < LEDA/geo/rat_ray.h >

Types

 rat_ray::coord_type the coordinate type (rational). rat_ray::point_type the point type (rat_point). rat_ray::float_type the corresponding floatin-point type (ray).

Creation

 rat_ray r(const rat_point& p, const 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(const rat_segment& s) introduces a variable r of type rat_ray. r is initialized to the (ratray(s.source(), s.target()). Precondition s is nontrivial. rat_ray r(const rat_point& p, const rat_vector& v) introduces a variable r of type rat_ray. r is initialized to ratray(p, p + v). rat_ray r introduces a variable r of type rat_ray. rat_ray r(const ray& r1, 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 r1.

Operations

 ray r.to_float() returns a floating point approximation of r. void r.normalize() simplifies the homogenous representation by calling point1().normalize() and point2().normlize(). 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(const 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(const rat_segment& s, rat_point& inter) returns true if r and s intersect. If so, a point of intersection is returned in inter. bool r.intersection(const rat_segment& s) test if r and s intersect. rat_ray r.translate(const rational& dx, const 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(const rat_vector& v) returns r + v, i.e., r translated by vector v. Precondition v.dim() = 2. rat_ray r + const rat_vector& v returns r translated by vector v. rat_ray r - const rat_vector& v returns r translated by vector - v. rat_ray r.rotate90(const rat_point& q, int i=1) returns r rotated about q by an angle of i x 90 degrees. If i > 0 the rotation is counter-clockwise otherwise it is clockwise. rat_ray r.reflect(const rat_point& p, const rat_point& q) returns r reflected across the straight line passing through p and q. Precondition p q. rat_ray r.reflect(const rat_point& p) returns r reflected across point p. rat_ray r.reverse() returns r reversed. bool r.contains(const rat_point& p) decides whether r contains p. bool r.contains(const rat_segment& s) decides whether r contains s.

Non-Member Functions

 int orientation(const rat_ray& r, const 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(const rat_ray& r1, const rat_ray& r2) returns compare(slope(r1), slope(r2)).

Next: Straight Rational Lines ( Up: Basic Data Types for Previous: Rational Segments ( rat_segment   Contents   Index