next up previous contents index
Next: Straight Lines ( line Up: Basic Data Types for Previous: Segments ( segment )   Contents   Index


Straight Rays ( ray )

Definition

An instance r of the data type ray is a directed straight ray in the two-dimensional plane. The angle between a right oriented horizontal ray and r is called the direction of r .

#include < LEDA/geo/ray.h >

Types

ray::coord_type the coordinate type (double).

ray::point_type the point type (point).

Creation

ray r(const point& p, const point& q)
    introduces a variable r of type ray. r is initialized to the ray starting at point p and passing through point q .

ray r(const segment& s) introduces a variable r of type ray. r is initialized to ray(s.source(), s.target()) .

ray r(const point& p, const vector& v)
    introduces a variable r of type ray. r is initialized to ray(p, p + v) .

ray r(const point& p, double alpha)
    introduces a variable r of type ray. r is initialized to the ray starting at point p with direction alpha .

ray r introduces a variable r of type ray. r is initialized to the ray starting at the origin with direction 0.

ray r(const ray& r1, int) introduces a variable r of type ray. r is initialized to a copy of r1 . The second argument is for compatibility with rat_ray.

Operations

point r.source() returns the source of r.

point r.point1() returns the source of r.

point r.point2() returns a point on r different from r.source().

double r.direction() returns the direction of r.

double r.angle(const ray& s) returns the angle between r and s , i.e., s .direction() - r.direction().

bool r.is_vertical() returns true iff r is vertical.

bool r.is_horizontal() returns true iff r is horizontal.

double r.slope() returns the slope of the straight line underlying r.
Precondition r is not vertical.

bool r.intersection(const ray& s, point& inter)
    if r and s intersect in a single point this point is assigned to inter and the result is true, otherwise the result is false.

bool r.intersection(const segment& s, point& inter)
    if r and s intersect in a single point this point is assigned to inter and the result is true, otherwise the result is false.

bool r.intersection(const segment& s)
    test if r and s intersect.

ray r.translate_by_angle(double a, double d)
    returns r translated in direction a by distance d .

ray r.translate(double dx, double dy)
    returns r translated by vector (dx, dy) .

ray r.translate(const vector& v)
    returns r translated by vector v
Precondition v .dim() = 2.

ray r + const vector& v returns r translated by vector v .

ray r - const vector& v returns r translated by vector - v .

ray r.rotate(const point& q, double a)
    returns r rotated about point q by angle a .

ray r.rotate(double a) returns r .rotate( point(0, 0), a ).

ray r.rotate90(const 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.

ray r.reflect(const point& p, const point& q)
    returns r reflected across the straight line passing through p and q .

ray r.reflect(const point& p) returns r reflected across point p .

ray r.reverse() returns r reversed.

bool r.contains(const point& ) decides whether r contains p .

bool r.contains(const segment& )
    decides whether r contains s .

Non-Member Functions

int orientation(const ray& r, const point& p)
    computes orientation(a , b , p ), where a $ \not=$b and a and b appear in this order on ray r .

int cmp_slopes(const ray& r1, const ray& r2)
    returns compare(slope(r1 ), slope(r2 )) where slope(ri) denotes the slope of the straight line underlying ri .


next up previous contents index
Next: Straight Lines ( line Up: Basic Data Types for Previous: Segments ( segment )   Contents   Index
Christian Uhrig 2017-04-07