A quadratic plane curve. More...
#include <vgl_conic.h>
Public Types | |
enum | vgl_conic_type { no_type = 0, real_ellipse, real_circle, imaginary_ellipse, imaginary_circle, hyperbola, parabola, real_intersecting_lines, complex_intersecting_lines, real_parallel_lines, complex_parallel_lines, coincident_lines, num_conic_types } |
Public Member Functions | |
vgl_conic_type | type () const |
vcl_string | real_type () const |
Returns the type of the conic as a string. | |
T | a () const |
Returns the coefficient of . | |
T | b () const |
Returns the coefficient of . | |
T | c () const |
Returns the coefficient of . | |
T | d () const |
Returns the coefficient of . | |
T | e () const |
Returns the coefficient of . | |
T | f () const |
Returns the coefficient of . | |
vgl_conic () | |
vgl_conic (T a, T b, T c, T d, T e, T f) | |
constructor using polynomial coefficients. | |
vgl_conic (T const coeff[]) | |
constructor using polynomial coefficients, given as a C array. | |
vgl_conic (vgl_homg_point_2d< T > const &c, T rx, T ry, T theta) | |
constructor using centre, signed radii, and angle. | |
void | set (T a, T b, T c, T d, T e, T f) |
set or reset the conic using polynomial coefficients. | |
bool | operator== (vgl_conic< T > const &c) const |
comparison operator. | |
bool | is_degenerate () const |
Returns true if this conic is degenerate, i.e., if it consists of 2 lines. | |
bool | is_central () const |
Returns true if a central conic, i.e., an ellipse, circle, or hyperbola. | |
bool | contains (vgl_homg_point_2d< T > const &pt) const |
Returns true if the point pt belongs to the conic. | |
vcl_list< vgl_homg_line_2d< T > > | components () const |
Returns the list of component lines, when degenerate and real components. | |
vgl_homg_line_2d< T > | polar_line (vgl_homg_point_2d< T > const &p) const |
Returns the polar line of the given point, w.r.t. this conic. | |
vgl_homg_point_2d< T > | polar_point (vgl_homg_line_2d< T > const &l) const |
Returns the polar point of the given line, w.r.t. this conic. | |
vgl_homg_line_2d< T > | tangent_at (vgl_homg_point_2d< T > const &p) const |
Returns the tangent to the conic in the point p, if p is on the conic. | |
vgl_homg_point_2d< T > | centre () const |
Returns the centre of the conic, or its point at infinity if a parabola. | |
double | curvature_at (vgl_point_2d< T > const &p) const |
Returns the curvature of the conic at point p, assuming p is on the conic. | |
bool | ellipse_geometry (double &xc, double &yc, double &major_axis_length, double &minor_axis_length, double &angle_in_radians) const |
Converts the coefficients to a geometric description of an ellipse. | |
vgl_conic | dual_conic () const |
Returns the dual or tangential representation of this conic. | |
vgl_conic | tangential_form () const |
Returns the dual or tangential representation of this conic. | |
void | translate_by (T x, T y) |
Modify this conic by translating it over distance x in the X direction and distance y in the Y direction. | |
Static Public Member Functions | |
static vgl_conic_type | type_by_name (vcl_string const &name) |
Returns the internal enum value corresponding to the string argument. | |
static vcl_string | type_by_number (vgl_conic_type type) |
Converts the conic type from enum (internal representation) to string. | |
Private Member Functions | |
void | set_type_from_equation () |
set conic type from polynomial coefficients and store in member type_. | |
Private Attributes | |
vgl_conic_type | type_ |
T | a_ |
coefficient of x^2 | |
T | b_ |
coefficient of xy | |
T | c_ |
coefficient of y^2 | |
T | d_ |
coefficient of xw | |
T | e_ |
coefficient of yw | |
T | f_ |
coefficient of w^2 | |
Related Functions | |
(Note that these are not member functions.) | |
template<class T > | |
vcl_ostream & | operator<< (vcl_ostream &s, vgl_conic< T > const &c) |
Write "<vgl_conic aX^2+bXY+cY^2+dXW+eYW+fW^2>" to stream. | |
template<class T > | |
vcl_istream & | operator>> (vcl_istream &s, vgl_conic< T > &c) |
Read a b c d e f from stream. |
A quadratic plane curve.
A conic is either an ellipse (or circle), a hyperbola, or a parabola. It is represented by a quadratic equation in two nonhomogeneous or three homogeneous coordinates. Conversely, every quadratic equation represents a conic, be it that it can be degenerate: either in two (intersecting or parallel) lines, or in two coincident lines. Also, it can have no "visible", real points, when it is an imaginary ellipse, or consist of two complementary imaginary lines in which case it only has one real point, which could still be at infinity.
These 11 cases are the possible values of vgl_conic::real_type(). The default constructor sets the type to "invalid conic"; otherwise the correct type is automatically set when the equation of the conic is given to the constructor that takes 6 numeric values (a,b,c,d,e,f): the cartesian equation is then ; the homogeneous equation is . (Sometimes with for .) The numeric type (typically double or float) is the template argument of this class.
When the conic is degenerate and consists of two lines, the method components() returns a list of two (possibly identical) lines. Otherwise, this method returns an empty list.
Definition at line 67 of file vgl_conic.h.
enum vgl_conic::vgl_conic_type |
Definition at line 70 of file vgl_conic.h.
Definition at line 137 of file vgl_conic.h.
constructor using polynomial coefficients.
The order of the coefficients is: , , , , , , where is the homogeneous coordinate (sometimes denoted by ).
Definition at line 97 of file vgl_conic.txx.
constructor using polynomial coefficients, given as a C array.
constructor using polynomial coefficients.
The order of the coefficients is: , , , , , , where is the homogeneous coordinate (sometimes denoted by ).
Definition at line 88 of file vgl_conic.txx.
vgl_conic< T >::vgl_conic | ( | vgl_homg_point_2d< T > const & | c, |
T | rx, | ||
T | ry, | ||
T | theta | ||
) |
constructor using centre, signed radii, and angle.
ctor using centre, signed radii, and angle, or (for parabola) top + eccentricity.
This constructor can only be used for non-degenerate, real conics: If the centre point c is a finite point and rx and ry have the same sign, an ellipse is defined (any ellipse can uniquely be specified this way); rx is the length of one main axis, ry of the other axis. Hyperbolas are obtained if rx and ry have opposite sign; the positive one determines the distance from bots tops to the centre, and the other one specified the 'minor' axis length. The rotation is about the centre of the ellipse or hyperbola, measured counterclockwise from the X axis. A parabola is obtained when the centre has w()=0, i.e., is a point at infinity. In that case (rx,ry) is the top, and theta is an eccentricity parameter (since the centre already specifies the direction of the symmetry axis).
Definition at line 105 of file vgl_conic.txx.
T vgl_conic< T >::a | ( | ) | const [inline] |
Returns the coefficient of .
Definition at line 117 of file vgl_conic.h.
T vgl_conic< T >::b | ( | ) | const [inline] |
Returns the coefficient of .
Definition at line 120 of file vgl_conic.h.
T vgl_conic< T >::c | ( | ) | const [inline] |
Returns the coefficient of .
Definition at line 123 of file vgl_conic.h.
vgl_homg_point_2d<T> vgl_conic< T >::centre | ( | ) | const [inline] |
Returns the centre of the conic, or its point at infinity if a parabola.
When two intersecting or parallel lines, returns their intersection point. In all cases this is the polar point of the line at infinity.
Definition at line 242 of file vgl_conic.h.
vcl_list< vgl_homg_line_2d< T > > vgl_conic< T >::components | ( | ) | const |
Returns the list of component lines, when degenerate and real components.
Otherwise returns an empty list. If two coinciding lines, the list contains two identical elements. Hence this list always has length 0 or 2.
Otherwise returns an empty list.
Definition at line 237 of file vgl_conic.txx.
bool vgl_conic< T >::contains | ( | vgl_homg_point_2d< T > const & | pt | ) | const |
Returns true if the point pt belongs to the conic.
I.e., if it exactly satisfies the conic equation. Beware of rounding for floating point type T! An "almost" returns false!
Definition at line 184 of file vgl_conic.txx.
double vgl_conic< T >::curvature_at | ( | vgl_point_2d< T > const & | p | ) | const |
Returns the curvature of the conic at point p, assuming p is on the conic.
Definition at line 359 of file vgl_conic.txx.
T vgl_conic< T >::d | ( | ) | const [inline] |
Returns the coefficient of .
Definition at line 126 of file vgl_conic.h.
Returns the dual or tangential representation of this conic.
The homogeneous coordinates of the points belonging to the dual conic are the coefficients of the equations of all tangents to the original conic.
Definition at line 323 of file vgl_conic.txx.
T vgl_conic< T >::e | ( | ) | const [inline] |
Returns the coefficient of .
Definition at line 129 of file vgl_conic.h.
bool vgl_conic< T >::ellipse_geometry | ( | double & | xc, |
double & | yc, | ||
double & | major_axis_length, | ||
double & | minor_axis_length, | ||
double & | angle_in_radians | ||
) | const |
Converts the coefficients to a geometric description of an ellipse.
return a geometric description of the conic if an ellipse.
Returns false if the conic is not an ellipse. Double is appropriate since integer coefficients can produce non-integer ellipse parameters.
The centre of the ellipse is (xc, yc)
Definition at line 201 of file vgl_conic.txx.
T vgl_conic< T >::f | ( | ) | const [inline] |
Returns the coefficient of .
Definition at line 132 of file vgl_conic.h.
bool vgl_conic< T >::is_central | ( | ) | const |
Returns true if a central conic, i.e., an ellipse, circle, or hyperbola.
Return true if a central conic.
Also the degenerate versions of these return true. Returns false if a parabola or two parallel or coinciding lines.
(This is an affine property, not a projective one.) Equivalent to saying that the line at infinity does not touch the conic.
Definition at line 305 of file vgl_conic.txx.
bool vgl_conic< T >::is_degenerate | ( | ) | const |
Returns true if this conic is degenerate, i.e., if it consists of 2 lines.
Definition at line 190 of file vgl_conic.txx.
comparison operator.
equality test.
Comparison is on the conic, not the equation coefficients. Hence two conics are identical if their coefficient vectors are multiples of each other.
Definition at line 56 of file vgl_conic.txx.
vgl_homg_line_2d< T > vgl_conic< T >::polar_line | ( | vgl_homg_point_2d< T > const & | p | ) | const |
Returns the polar line of the given point, w.r.t. this conic.
return the polar line of the homogeneous 2-D point p.
For a non-degenerate conic, the polar line of a point outside of the conic is the connection line of the two points on the conic that form the conic "contour" as seen from that point, i.e., the touch points of the two tangents to the conic going through the given point.
For a point on the conic, it is just the tangent in that point.
And for a point inside the conic, it is the set of all polar points of the lines through the given point. This set happens to be a straight line.
Definition at line 331 of file vgl_conic.txx.
vgl_homg_point_2d< T > vgl_conic< T >::polar_point | ( | vgl_homg_line_2d< T > const & | l | ) | const |
Returns the polar point of the given line, w.r.t. this conic.
return the polar point of the homogeneous 2-D line l.
For a non-degenerate conic, the polar point of a line that intersects the conic in two points is the intersection point of the two tangent lines though those two points. Hence it is the point of which this line is the polar line.
For a tangent line to the conic, it is just the tangent point.
And for a line not intersecting the conic, it is the common intersection point (inside the conic) of the polar lines of all points of that line.
Definition at line 340 of file vgl_conic.txx.
vcl_string vgl_conic< T >::real_type | ( | ) | const |
Returns the type of the conic as a string.
Returns the type name of the conic.
Possible returned strings are: "real ellipse", "real circle", "imaginary ellipse", "imaginary circle", "hyperbola", "parabola", "real intersecting lines", "complex intersecting lines", "real parallel lines", "complex parallel lines", "coincident lines". The default constructor sets the type to "invalid conic".
Definition at line 35 of file vgl_conic.txx.
void vgl_conic< T >::set | ( | T | a, |
T | b, | ||
T | c, | ||
T | d, | ||
T | e, | ||
T | f | ||
) |
set or reset the conic using polynomial coefficients.
set values.
The order of the coefficients is: , , , , , , where is the homogeneous coordinate (sometimes denoted by ).
Definition at line 79 of file vgl_conic.txx.
void vgl_conic< T >::set_type_from_equation | ( | ) | [private] |
set conic type from polynomial coefficients and store in member type_.
set conic type from polynomial coefficients.
This method must be called by all constructors (except the default constructor) and all methods that change the coefficients.
Definition at line 143 of file vgl_conic.txx.
vgl_homg_line_2d<T> vgl_conic< T >::tangent_at | ( | vgl_homg_point_2d< T > const & | p | ) | const [inline] |
Returns the tangent to the conic in the point p, if p is on the conic.
In general, returns the polar line of the point w.r.t. the conic.
Definition at line 237 of file vgl_conic.h.
Returns the dual or tangential representation of this conic.
Definition at line 262 of file vgl_conic.h.
void vgl_conic< T >::translate_by | ( | T | x, |
T | y | ||
) |
Modify this conic by translating it over distance x in the X direction and distance y in the Y direction.
Definition at line 314 of file vgl_conic.txx.
vgl_conic_type vgl_conic< T >::type | ( | ) | const [inline] |
Definition at line 98 of file vgl_conic.h.
vgl_conic< T >::vgl_conic_type vgl_conic< T >::type_by_name | ( | vcl_string const & | name | ) | [static] |
Returns the internal enum value corresponding to the string argument.
Useful for comparison purposes, or for use in "case" statements.
Definition at line 38 of file vgl_conic.txx.
static vcl_string vgl_conic< T >::type_by_number | ( | vgl_conic_type | type | ) | [static] |
Converts the conic type from enum (internal representation) to string.
vcl_ostream & operator<< | ( | vcl_ostream & | s, |
vgl_conic< T > const & | c | ||
) | [related] |
Write "<vgl_conic aX^2+bXY+cY^2+dXW+eYW+fW^2>" to stream.
vcl_istream & operator>> | ( | vcl_istream & | s, |
vgl_conic< T > & | c | ||
) | [related] |
Read a b c d e f from stream.
coefficient of x^2
Definition at line 90 of file vgl_conic.h.
coefficient of xy
Definition at line 91 of file vgl_conic.h.
coefficient of y^2
Definition at line 92 of file vgl_conic.h.
coefficient of xw
Definition at line 93 of file vgl_conic.h.
coefficient of yw
Definition at line 94 of file vgl_conic.h.
coefficient of w^2
Definition at line 95 of file vgl_conic.h.
vgl_conic_type vgl_conic< T >::type_ [private] |
Definition at line 89 of file vgl_conic.h.