Definition
An instance C of data type rat_circle is an oriented circle in the plane. A circle is defined by three points p_1, p_2, p_3 with rational coordinates (rat_points). The orientation of C is equal to the orientation of the three defining points, i.e., orientation(p_1,p_2,p_3). 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 . Assume now that p_1, p_2, p_3 are admissable. If they define the circle with center p_1 and radius zero. If p_1, p_2, and p_3 are collinear C is a straight line passing through p_1, p_2 and p_3 in this order and the center of C is undefined. If p_1, p_2, and p_3 are not collinear, C is the circle passing through them.
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). |
|
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 p_1. |
rat_point | C.point2() | returns p_2. |
rat_point | C.point3() | returns p_3. |
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. |