next up previous contents index
Next: Geometry Algorithms ( geo_alg Up: Basic Data Types for Previous: Straight Rational Lines (

     
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 counterclockwise 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}|! = 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/rat _circle.h >

Creation

rat_circle C(rat_point a, rat_point b, 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(rat_point a, 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(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(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 threee defining points of c.

Operations

circle C.to_circle() returns a floating point approximation of C.
int  C.orientation() returns the orientation of C.
rat_point C.center() returns the center of C.
Precondition: C has a center, i.e., it 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.
int  C.side_of(rat_point p) returns -1, +1, or 0 if p lies right of, left of, or on C respectively.
bool C.inside(rat_point p) returns true if p lies inside C, false otherwise.
bool C.outside(rat_point p) returns true if p lies outside C.
bool C.contains(rat_point p) returns true if p lies on C, false otherwise.
rat_circle  C.translate(rational dx, 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(rat_vector v) returns C translated by vector v.
rat_circle C + rat_vector v returns C translated by vector v.
rat_circle C - rat_vector v returns C translated by vector - v.
rat_circle  C.rotate90(rat_point q) returns C rotated about q by an angle of 90 degrees.
rat_circle  C.reflect(rat_point p, rat_point q)
    returns C reflected across the straight line passing through p and q.
rat_circle  C.reflect(rat_point p) returns C reflected across point p.
rat_circle  C.reverse() returns C reversed.
bool C == D returns true if C and D are equal as oriented circles
bool C.equal_as_sets(rat_circle C1, rat_circle C2)
    returns true if C1 and C2 are equal as unoriented circles
ostream& ostream& out << 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: Geometry Algorithms ( geo_alg Up: Basic Data Types for Previous: Straight Rational Lines (
LEDA research project
1999-04-23