The class Arr_conic_traits_2<RatKernel,AlgKernel,NtTraits> is a model of the ArrangementTraits_2 concept and can be used to construct and maintain arrangements of bounded segments of algebraic curves of degree at most, also known as conic curves.
A general conic curve is the locus of all points satisfying the equation: , where:
A bounded conic arc is defined as either of the following:
A very useful subset of the set of conic arcs are line segments and circular arcs, as arrangements of circular arcs and line segments have some interesting applications (e.g. offsetting polygons, motion planning for a disc robot, etc.). Circular arcs and line segment are simpler objects and can be dealt with more efficiently than arbitrary arcs. For these reasons, it is possible to construct conic arcs from segments and from circles. Using these constructors is highly recommended: It is more straightforward and also speeds up the arrangement construction. However, in case the set of input curves contain only circular arcs and line segments, it is recommended to use the Arr_circle_segment_2 class to achieve faster running times.
In our representation, all conic coefficients (namely ) must be rational numbers. This guarantees that the coordinates of all arrangement vertices (in particular, those representing instersection points) are algebraic numbers of degree (a real number is an algebraic number of degree if there exist a polynomial with integer coefficient of degree such that ). We therefore require separate representations of the curve coefficients and the point coordiantes. The NtTraits should be instantiated with a class that defines nested Integer, Rational and Algebraic number types and supports various operations on them, yielding certified computation results (for example, it can convert rational numbers to algebraic numbers and can compute roots of polynomials with integer coefficients). The other template parameters, RatKernel and AlgKernel should be geometric kernels templated with the NtTraits::Rational and NtTraits::Algebraic number types, repectively. It is recommended to instantiate the CORE_algebraic_number_traits class as the NtTraits parameter, with Cartesian<NtTraits::Rational> and Cartesian<NtTraits::Algebraic> instantiating the two kernel types, respectively. The number types in this case are provided by the CORE library, with its ability to exactly represent simple algebraic numbers.
The traits class inherits its point type from AlgKernel::Point_2, and defines a curve and -monotone curve types, as detailed below.
#include <CGAL/Arr_conic_traits_2.h>
The Curve_2 class nested within the conic-arc traits can represent arbitrary conic arcs and support their construction in various ways. The copy and default constructor as well as the assignment and equality operators are provided for conic arcs. In addition, an operator<< for the curves is defined for standard output streams.
| |
the NtTraits::Rational type
(and also the RatKernel::FT type).
| |
| |
the NtTraits::Algebraic type
(and also the AlgKernel::FT type).
|
| |||
constructs an arc corresponding to the line segment seg.
| |||
| |||
constructs an arc corresponding to the full circle circ
(note that this circle has a center point with rational coordinates
and rational squared radius).
| |||
| |||
constructs a circular arc supported by the circle circ, going
in the given orientation o from the source point ps to
its target point pt. Precondition: ps and pt both lie on the circle circ. Precondition: o is not COLLINEAR.
| |||
| |||
constructs a circular arc going from p1 (its source point)
through p2 to p3 (its target point). Note that all three
points have rational coordinates. The orientation of the arc is
determined automatically. Precondition: The three points are not collinear.
| |||
| |||
constructs a conic arc that corresponds to the full conic curve
. Precondition: As a conic arc must be bounded, the given curve must be an ellipse, that is .
| |||
| |||
constructs a conic arc supported by the conic curve
, going
in the given orientation o from the source point ps to
its target point pt. Precondition: ps and pt both satisfy the equation of the supporting conic curve and define a bounded segment of this curve (e.g. in case of a hyperbolic arc, both point should be located on the same branch of the hyperbola). Precondition: o is not COLLINEAR if the supporting conic is curves, and must be COLLINEAR if it is not curved (a line or a line-pair).
| |||
| |||
constructs a conic arc going from p1 (its source point)
through p2, p3 and p4 (in this order) to p5
(its target point). Note that all five points have rational coordinates.
The orientation of the arc is determined automatically. Precondition: No three points of the five are not collinear. Precondition: The five points define a valid arc, in their given order.
| |||
| |||
constructs a conic arc supported by the conic curve
, going
in the given orientation o from its source point to its target
point. In this case only some approximations of the endpoints
(app_ps and app_pt, repsectively) is available,
and their exact locations are given implicitly, specified by the
intersections of the supporting conic curve with
and
, repsectively. Precondition: The two auxiliary curves specifying the endpoints really intersect with the supporting conic curve, such that the arc endpoints define a bounded segment of the supporting curve (e.g. in case of a hyperbolic arc, both point should be located on the same branch of the hyperbola). Precondition: o is not COLLINEAR if the supporting conic is curves, and must be COLLINEAR if it is not curved (a line or a line-pair).
|
|
| indicates whether a is a valid conic arc. As the precondition to some of the constructor listed above are quite complicated, their violation does not cause the program to abort. Instead, the constructed arc is invalid (a defaultly constructed arc is also invalid). It is however recommended to check that a constructed arc is valid before inserting it to an arrangement, as this operation will cause the program to abort. |
|
| determines whether the arc is -monotone, namely each vertical line intersects it at most once. A vertical line segment is also considered (weakly) -monotone. |
|
| determines whether the arc is -monotone, namely each horizontal line intersects it at most once. A horizontal line segment is also considered (weakly) -monotone. |
|
| indicates whether the arc represents a full conic curve (en ellipse or a circle). |
The six following methods return the coefficients of the supported conic, after their conversion to integer number (reprsented by the Integer type of the NtTraits class):
| ||
| returns the coefficient of . | |
| ||
| returns the coefficient of . | |
| ||
| returns the coefficient of . | |
| ||
| returns the coefficient of . | |
| ||
| returns the coefficient of . | |
| ||
| returns the free coefficient. | |
|
|
returns the source point of the arc. Precondition: a is not a full conic curve. |
|
|
returns the target point of the arc. Precondition: a is not a full conic curve. |
|
| returns the orientation of the arc. |
|
| return a bounding box of the arc a. |
|
| |
sets a new source point for the conic arc. Precondition: ps lies on the supporting conic of a. | ||
|
| |
sets a new target point for the conic arc. Precondition: pt lies on the supporting conic of a. |
The X_monotone_curve_2 class nested within the conic-arc traits is used to represent -monotone conic arcs. It inherits from the Curve_2 type, therefore supports the access methods and the operations listed above.
For efficiency reasons, we recommend users not to construct -monotone conic arc directly, but rather use the Make_x_monotone_2 functor supplied by the conic-arc traits class to convert conic curves to -monotone curves.
| |||
converts the given arc to an -monotone arc. Precondition: arc is -monotone.
|
|
| returns the left (lexicographically smaller) endpoint of xa. |
|
| returns the right (lexicographically larger) endpoint of xa. |