Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Related Functions | List of all members
vgl_conic< T > Class Template Reference

A quadratic plane curve. More...

#include <vgl_conic.h>

Inheritance diagram for vgl_conic< T >:
Inheritance graph
[legend]

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
 
std::string real_type () const
 Returns the type of the conic as a string. More...
 
a () const
 Returns the coefficient of $X^2$. More...
 
b () const
 Returns the coefficient of $XY$. More...
 
c () const
 Returns the coefficient of $Y^2$. More...
 
d () const
 Returns the coefficient of $XW$. More...
 
e () const
 Returns the coefficient of $YW$. More...
 
f () const
 Returns the coefficient of $W^2$. More...
 
 vgl_conic ()
 
 vgl_conic (T a, T b, T c, T d, T e, T f)
 constructor using polynomial coefficients. More...
 
 vgl_conic (T const coeff[])
 constructor using polynomial coefficients, given as a C array. More...
 
 vgl_conic (vgl_homg_point_2d< T > const &c, T rx, T ry, T theta)
 constructor using centre, signed radii, and angle. More...
 
void set (T a, T b, T c, T d, T e, T f)
 set or reset the conic using polynomial coefficients. More...
 
bool operator== (vgl_conic< T > const &c) const
 comparison operator. More...
 
bool is_degenerate () const
 Returns true if this conic is degenerate, i.e., if it consists of 2 lines. More...
 
bool is_central () const
 Returns true if a central conic, i.e., an ellipse, circle, or hyperbola. More...
 
bool contains (vgl_homg_point_2d< T > const &pt) const
 Returns true if the point pt belongs to the conic. More...
 
std::list< vgl_homg_line_2d< T > > components () const
 Returns the list of component lines, when degenerate and real components. More...
 
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. More...
 
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. More...
 
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. More...
 
vgl_homg_point_2d< T > centre () const
 Returns the centre of the conic, or its point at infinity if a parabola. More...
 
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. More...
 
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. More...
 
vgl_conic dual_conic () const
 Returns the dual or tangential representation of this conic. More...
 
vgl_conic tangential_form () const
 Returns the dual or tangential representation of this conic. More...
 
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. More...
 

Static Public Member Functions

static vgl_conic_type type_by_name (std::string const &name)
 Returns the internal enum value corresponding to the string argument. More...
 
static std::string type_by_number (vgl_conic_type type)
 Converts the conic type from enum (internal representation) to string. More...
 

Private Member Functions

void set_type_from_equation ()
 set conic type from polynomial coefficients and store in member type_. More...
 

Private Attributes

vgl_conic_type type_
 
a_
 coefficient of x^2 More...
 
b_
 coefficient of xy More...
 
c_
 coefficient of y^2 More...
 
d_
 coefficient of xw More...
 
e_
 coefficient of yw More...
 
f_
 coefficient of w^2 More...
 

Related Functions

(Note that these are not member functions.)

template<class T >
std::ostream & operator<< (std::ostream &s, vgl_conic< T > const &c)
 Write "<vgl_conic aX^2+bXY+cY^2+dXW+eYW+fW^2>" to stream. More...
 
template<class T >
std::istream & operator>> (std::istream &s, vgl_conic< T > &c)
 Read a b c d e f from stream. More...
 

Detailed Description

template<class T>
class vgl_conic< T >

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 $ax^2 + bxy + cy^2 + dx + ey + f = 0$; the homogeneous equation is $ax^2 + bxy + cy^2 + dxw + eyw + fw^2 = 0$. (Sometimes with $z$ for $w$.) 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 70 of file vgl_conic.h.

Member Enumeration Documentation

◆ vgl_conic_type

template<class T>
enum vgl_conic::vgl_conic_type
Enumerator
no_type 
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 

Definition at line 73 of file vgl_conic.h.

Constructor & Destructor Documentation

◆ vgl_conic() [1/4]

template<class T>
vgl_conic< T >::vgl_conic ( )
inline

Definition at line 140 of file vgl_conic.h.

◆ vgl_conic() [2/4]

template<class T>
vgl_conic< T >::vgl_conic ( a,
b,
c,
d,
e,
f 
)

constructor using polynomial coefficients.

The order of the coefficients is: $X^2$, $XY$, $Y^2$, $XW$, $YW$, $W^2$, where $W$ is the homogeneous coordinate (sometimes denoted by $Z$).

Definition at line 98 of file vgl_conic.hxx.

◆ vgl_conic() [3/4]

template<class T>
vgl_conic< T >::vgl_conic ( T const  coeff[])

constructor using polynomial coefficients, given as a C array.

constructor using polynomial coefficients.

The order of the coefficients is: $X^2$, $XY$, $Y^2$, $XW$, $YW$, $W^2$, where $W$ is the homogeneous coordinate (sometimes denoted by $Z$).

Definition at line 89 of file vgl_conic.hxx.

◆ vgl_conic() [4/4]

template<class T>
vgl_conic< T >::vgl_conic ( vgl_homg_point_2d< T > const &  c,
rx,
ry,
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 106 of file vgl_conic.hxx.

Member Function Documentation

◆ a()

template<class T>
T vgl_conic< T >::a ( ) const
inline

Returns the coefficient of $X^2$.

Definition at line 120 of file vgl_conic.h.

◆ b()

template<class T>
T vgl_conic< T >::b ( ) const
inline

Returns the coefficient of $XY$.

Definition at line 123 of file vgl_conic.h.

◆ c()

template<class T>
T vgl_conic< T >::c ( ) const
inline

Returns the coefficient of $Y^2$.

Definition at line 126 of file vgl_conic.h.

◆ centre()

template<class T>
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 245 of file vgl_conic.h.

◆ components()

template<class T >
std::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 238 of file vgl_conic.hxx.

◆ contains()

template<class T>
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 185 of file vgl_conic.hxx.

◆ curvature_at()

template<class T>
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 360 of file vgl_conic.hxx.

◆ d()

template<class T>
T vgl_conic< T >::d ( ) const
inline

Returns the coefficient of $XW$.

Definition at line 129 of file vgl_conic.h.

◆ dual_conic()

template<class T >
vgl_conic< T > vgl_conic< T >::dual_conic ( ) const

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 324 of file vgl_conic.hxx.

◆ e()

template<class T>
T vgl_conic< T >::e ( ) const
inline

Returns the coefficient of $YW$.

Definition at line 132 of file vgl_conic.h.

◆ ellipse_geometry()

template<class T >
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 202 of file vgl_conic.hxx.

◆ f()

template<class T>
T vgl_conic< T >::f ( ) const
inline

Returns the coefficient of $W^2$.

Definition at line 135 of file vgl_conic.h.

◆ is_central()

template<class T >
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 306 of file vgl_conic.hxx.

◆ is_degenerate()

template<class T >
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 191 of file vgl_conic.hxx.

◆ operator==()

template<class T>
bool vgl_conic< T >::operator== ( vgl_conic< T > const &  c) const

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 57 of file vgl_conic.hxx.

◆ polar_line()

template<class T>
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 332 of file vgl_conic.hxx.

◆ polar_point()

template<class T>
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 341 of file vgl_conic.hxx.

◆ real_type()

template<class T >
std::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 36 of file vgl_conic.hxx.

◆ set()

template<class T>
void vgl_conic< T >::set ( a,
b,
c,
d,
e,
f 
)

set or reset the conic using polynomial coefficients.

set values.

The order of the coefficients is: $X^2$, $XY$, $Y^2$, $XW$, $YW$, $W^2$, where $W$ is the homogeneous coordinate (sometimes denoted by $Z$).

Definition at line 80 of file vgl_conic.hxx.

◆ set_type_from_equation()

template<class T >
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 144 of file vgl_conic.hxx.

◆ tangent_at()

template<class T>
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 240 of file vgl_conic.h.

◆ tangential_form()

template<class T>
vgl_conic vgl_conic< T >::tangential_form ( ) const
inline

Returns the dual or tangential representation of this conic.

Definition at line 265 of file vgl_conic.h.

◆ translate_by()

template<class T>
void vgl_conic< T >::translate_by ( x,
y 
)

Modify this conic by translating it over distance x in the X direction and distance y in the Y direction.

Definition at line 315 of file vgl_conic.hxx.

◆ type()

template<class T>
vgl_conic_type vgl_conic< T >::type ( ) const
inline

Definition at line 101 of file vgl_conic.h.

◆ type_by_name()

template<class T >
vgl_conic< T >::vgl_conic_type vgl_conic< T >::type_by_name ( std::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 39 of file vgl_conic.hxx.

◆ type_by_number()

template<class T>
std::string vgl_conic< T >::type_by_number ( vgl_conic_type  type)
static

Converts the conic type from enum (internal representation) to string.

Definition at line 48 of file vgl_conic.hxx.

Friends And Related Function Documentation

◆ operator<<()

template<class T >
std::ostream & operator<< ( std::ostream &  s,
vgl_conic< T > const &  c 
)
related

Write "<vgl_conic aX^2+bXY+cY^2+dXW+eYW+fW^2>" to stream.

◆ operator>>()

template<class T >
std::istream & operator>> ( std::istream &  s,
vgl_conic< T > &  c 
)
related

Read a b c d e f from stream.

Member Data Documentation

◆ a_

template<class T>
T vgl_conic< T >::a_
private

coefficient of x^2

Definition at line 93 of file vgl_conic.h.

◆ b_

template<class T>
T vgl_conic< T >::b_
private

coefficient of xy

Definition at line 94 of file vgl_conic.h.

◆ c_

template<class T>
T vgl_conic< T >::c_
private

coefficient of y^2

Definition at line 95 of file vgl_conic.h.

◆ d_

template<class T>
T vgl_conic< T >::d_
private

coefficient of xw

Definition at line 96 of file vgl_conic.h.

◆ e_

template<class T>
T vgl_conic< T >::e_
private

coefficient of yw

Definition at line 97 of file vgl_conic.h.

◆ f_

template<class T>
T vgl_conic< T >::f_
private

coefficient of w^2

Definition at line 98 of file vgl_conic.h.

◆ type_

template<class T>
vgl_conic_type vgl_conic< T >::type_
private

Definition at line 92 of file vgl_conic.h.


The documentation for this class was generated from the following files: