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

     
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/ray.h >

Types

ray::coord_type  the coordinate type (double).

ray::point_type  the point type (point).

Creation

ray r(point p, 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(segment s) introduces a variable r of type ray. r is initialized to ray(s.source(), s.target()).

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

ray r(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(ray r, int) introduces a variable r of type ray. r is initialized to a copy of r. 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(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(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(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.

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(vector v) returns r translated by vector v
Precondition v.dim() = 2.

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

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

ray  r.rotate(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(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(point p, point q)
    returns r reflected across the straight line passing through p and q.

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

ray  r.reverse() returns r reversed.

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

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

Non-Member Functions

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

int  cmp_slopes(ray r1, 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 )

© Copyright 1995-2002, Algorithmic Solutions Software GmbH. All rights reserved.
2002-10-16