A conic equation represents the intersection of an extended cone and a plane. The equation below represents an ellipse with axes aligned with the coordinate frame and with center at the origin.

x^{2} |
+ | y^{2} |
= 1 |

a^{2} |
b^{2} |

This equation can be changed by a translation that moves the center of the ellipse to a point {*p*, *q*} by replacing *x*, *y* using:

x |
← x − p |

y |
← y − q |

It can also be changed by a rotation by angle θ around the coordinate origin by again replacing *x*, *y* using:

x |
← x cos θ + y sin θ |

y |
← − x sin θ + y cos θ |

If the ellipse is translated or rotated or both, the resulting equation will have terms in *x*^{2}, *xy*, *y*^{2}, *x*, *y*, and a constant. Transformation of the normal equations for a parabola or a hyperbola would also produce a new equation with these terms. Then, the general form of the equation of a conic section is:

Ax^{2} + Bxy + Cy^{2} + Dx + Ey + F = 0 |

The general conic section has five independent coefficients (the equation can be divided by any of the six coefficients without changing the equality). Therefore, five points are necessary and sufficient to define a unique conic section. That is, one and only one conic section can be drawn through five points.

One method to determine the five coefficients is to substitute each of the {*x*, *y*} points into the equation to obtain five linear equations using five independent coefficients as variables. For example, to find the conic section that fits these five points:

{0.5, 8.0}, {1.0, 4.0}, {2.0, 2.0}, {4.0, 1.0}, {8.0, 0.5} |

Solve the system of equations (and choosing *F* = 4):

0.25A | + | 4.00B | + | 64.00C | + | 0.50D | + | 8.00E | + | 4.00 | = 0 |

1.00A | + | 4.00B | + | 16.00C | + | 1.00D | + | 4.00E | + | 4.00 | = 0 |

4.00A | + | 4.00B | + | 4.00C | + | 2.00D | + | 2.00E | + | 4.00 | = 0 |

16.00A | + | 4.00B | + | 1.00C | + | 4.00D | + | 1.00E | + | 4.00 | = 0 |

64.00A | + | 4.00B | + | 0.25C | + | 8.00D | + | 0.50E | + | 4.00 | = 0 |

to obtain the solution:

− xy + 4.0000 = 0 |

The program below uses Gaussian elimination to obtain the coefficients of a conic equation given five points.

constN :int:= 5typepoint :recordx, y :realend recordtypefivepoints :array[N]ofpointtypeconic :array[N+1]of realvara :array[N,N+1]of realvarx :array[N]of realvarconstant :real:= 6% arbitraryprogramvart :intvarr, c : conicvarp : fivepointsput"\nConic from 5 points" p[1].x := -6.0 p[1].y := 6.0 p[2].x := -4.0 p[2].y := 3.0 p[3].x := -2.0 p[3].y := 2.0 p[4].x := 0.0 p[4].y := 3.0 p[5].x := 2.0 p[5].y := 6.0 initialize( p )% array of conic equationsifeliminatethen% lower diagonal elementssubstitute% and solve for xset_conic( c, x[1], x[2], x[3], x[4], x[5], constant ) put_conic( c )elseput"singular matrix!"end ifend program% set values of conic coefficient arrayprocedureset_conic(varcoef : conic, a, b, c, d, e, f :real) coef[1] := a coef[2] := b coef[3] := c coef[4] := d coef[5] := e coef[6] := fend procedure% display a general conic equationprocedureput_conic(varx : conic )vari :intvars :boolean:=falsefori := 1...6docontinue whenx[i] = 0ifx[i] < 0thenput" - "...elsif(i > 1)andsthenput" + "...end ifs :=trueif(abs(x[i]) ~= 1)or(i = 6)thenputabs(x[i]):5:4...ifi ~= 6thenput'·'...end ifend ifcaseiofvalue1:put"x²"...value2:put"x·y"...value3:put"y²"...value4:put"x"...value5:put"y"...end caseend forput" = 0"end procedure% set elements of matrix Aprocedureinitialize(varp : fivepoints )vari :intfori := 1...5doa[i,1] := p[i].x^2% Aa[i,2] := p[i].x * p[i].y% Ba[i,3] := p[i].y^2% Ca[i,4] := p[i].x% Da[i,5] := p[i].y% Ea[i,6] := -constant% -Fx[i] := 0end forend procedure% convert matrix A to upper diagonal formfunctioneliminate :booleanvari, j, k, max_row :intvart :realvarok :boolean:=truefori := 1...Ndo% find row with maximum in column imax_row := iforj := i...Ndoifabs( a[j,i] ) > abs( a[max_row,i] )thenmax_row := jend ifend for% swap max row with row i of A and bfork := i...N+1dot := a[i,k] a[i,k] := a[max_row,k] a[max_row,k] := tend for% eliminate lower diagonal elementsforj := i+1 ... Ndofor decreasingk := N+1...idoifa[i,i] = 0.0thenok :=falseelsea[j,k] := a[j,k] - a[i,k] * a[j,i] / a[i,i]end ifend forend forend for% need to check last diagonal elementifa[N,N] = 0.0thenok :=falseend ifreturnokend function% compute the values of vector x starting from the bottomproceduresubstitutevarj, k :intvart :realfor decreasingj := N...1dot := 0.0fork := j+1...Ndot := t + a[j,k] * x[k]end forx[j] := ( a[j,N+1] - t ) / a[j,j]end forend procedure% return the absolute value of argumentfunctionabs( x :real) :realifx < 0thenx := -xend ifreturnxend function

Conic from 5 points 0.5000·x² + 0.0000·x·y + 0.0000·y² + 2.0000·x - 2.0000·y + 6.0000 = 0

Copyright © 2005, Stephen R. Schmitt