next up previous contents index
Next: Rational Triangles ( rat_triangle Up: Basic Data Types for Previous: Straight Rational Lines (   Contents   Index


Rational Circles ( rat_circle )

Definition

An instance C of data type rat_circle is an oriented circle in the plane. A circle is defined by three points p1, p2, p3 with rational coordinates (rat_points). The orientation of C is equal to the orientation of the three defining points, i.e., orientation(p1, p2, p3). Positive orientation corresponds to counter-clockwise orientation and negative orientation corresponds to clockwise orientation.

Some triples of points are unsuitable for defining a circle. A triple is admissable if |{p1, p2, p3}| $\not=$2. Assume now that p1, p2, p3 are admissable. If |{p1, p2, p3}| = 1 they define the circle with center p1 and radius zero. If p1, p2, and p3 are collinear C is a straight line passing through p1, p2 and p3 in this order and the center of C is undefined. If p1, p2, and p3 are not collinear, C is the circle passing through them.

#include < LEDA/geo/rat_circle.h >

Types

rat_circle::coord_type the coordinate type (rational).

rat_circle::point_type the point type (rat_point).

rat_circle::float_type the corresponding floatin-point type (circle).

Creation

rat_circle C(const rat_point& a, const rat_point& b, const rat_point& c)
    introduces a variable C of type rat$\_$circle. C is initialized to the circle through points a, b, and c.
Precondition a, b, and c are admissable.

rat_circle C(const rat_point& a, const rat_point& b)
    introduces a variable C of type circle. C is initialized to the counter-clockwise oriented circle with center a passing through b.

rat_circle C(const rat_point& a) introduces a variable C of type circle. C is initialized to the trivial circle with center a.

rat_circle C introduces a variable C of type rat$\_$circle. C is initialized to the trivial circle centered at (0, 0).

rat_circle C(const circle& c, int prec = rat_point::default_precision)
    introduces a variable C of type rat_circle. C is initialized to the circle obtained by approximating three defining points of c.

Operations

circle C.to_float() returns a floating point approximation of C.

void C.normalize() simplifies the homogenous representation by normalizing p1, p2, and p3.

int C.orientation() returns the orientation of C.

rat_point C.center() returns the center of C.
Precondition C has a center, i.e., is not a line.

rat_point C.point1() returns p1.

rat_point C.point2() returns p2.

rat_point C.point3() returns p3.

rational C.sqr_radius() returns the square of the radius of C.

rat_point C.point_on_circle(double alpha, double epsilon)
    returns a point p on C such that the angle of p differs from alpha by at most epsilon.

bool C.is_degenerate() returns true if the defining points are collinear.

bool C.is_trivial() returns true if C has radius zero.

bool C.is_line() returns true if C is a line.

rat_line C.to_line() returns line(point1(), point3()).

int C.side_of(const rat_point& p)
    returns -1, +1, or 0 if p lies right of, left of, or on C respectively.

bool C.inside(const rat_point& p)
    returns true iff p lies inside of C.

bool C.outside(const rat_point& p)
    returns true iff p lies outside of C.

bool C.contains(const rat_point& p)
    returns true iff p lies on C.

rat_circle C.translate(const rational& dx, const rational& dy)
    returns C translated by vector (dx, dy).

rat_circle C.translate(integer dx, integer dy, integer dw)
    returns C translated by vector (dx/dw, dy/dw).

rat_circle C.translate(const rat_vector& v)
    returns C translated by vector v.

rat_circle C + const rat_vector& v returns C translated by vector v.

rat_circle C - const rat_vector& v returns C translated by vector - v.

rat_circle C.rotate90(const rat_point& q, int i=1)
    returns C rotated by i x 90 degrees about q. If i > 0 the rotation is counter-clockwise otherwise it is clockwise.

rat_circle C.reflect(const rat_point& p, const rat_point& q)
    returns C reflected across the straight line passing through p and q.

rat_circle C.reflect(const rat_point& p)
    returns C reflected across point p.

rat_circle C.reverse() returns C reversed.

bool C == const rat_circle& D returns true if C and D are equal as oriented circles.

bool equal_as_sets(const rat_circle& C1, const rat_circle& C2)
    returns true if C1 and C2 are equal as unoriented circles.

bool radical_axis(const rat_circle& C1, const rat_circle& C2, rat_line& rad_axis)
    if the radical axis for C1 and C2 exists, it is assigned to rad_axis and true is returned; otherwise the result is false.

ostream& ostream& out « const rat_circle& c
    writes the three defining points.

istream& istream& in » rat_circle& c
    reads three points and assigns the circle defined by them to c.


next up previous contents index
Next: Rational Triangles ( rat_triangle Up: Basic Data Types for Previous: Straight Rational Lines (   Contents   Index