next up previous contents index
Next: Straight Real Lines ( Up: Basic Data Types for Previous: Real Segments ( real_segment   Contents   Index


Real Rays ( real_ray )

Definition

An instance r of the data type real_ray is a directed straight ray in the two-dimensional plane.

#include < LEDA/geo/real_ray.h >

Types

real_ray::coord_type the coordinate type (real).

real_ray::point_type the point type (real_point).

Creation

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

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

real_ray r(const real_point& p, const real_vector& v)
    introduces a variable r of type real_ray. r is initialized to real_ray(p,p+v).

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

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

real_ray r(const rat_ray& r1) introduces a variable r of type real_ray initialized to the ray r1.

Operations

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

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

real_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.

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

bool r.intersection(const real_ray& s, real_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 real_segment& s, real_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.

real_ray r.translate(real dx, real dy)
    returns r translated by vector (dx, dy).

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

real_ray r + const real_vector& v returns r translated by vector v.

real_ray r - const real_vector& v returns r translated by vector - v.

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

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

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

real_ray r.reverse() returns r reversed.

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

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

Non-Member Functions

int orientation(const real_ray& r, const real_point& p)
    computes orientation(a, b, p) (see the manual page of real_point), where a $\not=$b and a and b appear in this order on ray r.

int cmp_slopes(const real_ray& r1, const real_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 Real Lines ( Up: Basic Data Types for Previous: Real Segments ( real_segment   Contents   Index