Plot a conic (ellipse, hyperbola, or parabola) specified by a quadratic polynomial or by a symmetric 3x3 matrix.

1 2 3 4 5 |

`x` |
a 6-length vector or a symmetric 3x3 matrix |

`type` |
( |

`npoints` |
( |

`sym.axes` |
( |

`center` |
( |

`asymptotes` |
( |

`add` |
( |

`xlim` |
( |

`ylim` |
( |

`ax.lty` |
( |

`ax.col` |
( |

`as.lty` |
( |

`as.col` |
( |

`...` |
other parameters passed to the |

The `conicPlot`

function identifies the type of the conic and plots
it in the current graphical device.

The conic is specified either by a 6-length vector representing the
coefficients of the quadratic polynomial, or by the symmetric matrix
representing the associated quadratic form. See the function
`conicMatrix`

to build this matrix given the coefficients of
the polynomial.

It is usually a good idea to set explicitely the aspect ratio to 1 (as an
additional argument `asp=1`

in the `conicPlot`

function) in order
to avoid distorsions between the units of the x-axis and the y-axis. See
examples below.

The return value is invisible, i-e it is not printed on the console by default but can be stored in a variable. It is a list of relevant computed values corresponding to various elements of the conic. The following elements can be found in the return list, depending on the kind of the conic:

`kind` |
the kind of the conic: |

`axes` |
the symmetry axes. See also the function |

`center` |
the center of the conic. See also the function |

`asymptotes` |
the slopes of the asymptotes. See also the function |

`vertices` |
the vertices of the conic. |

`foci` |
the focal points of the conic. |

`eccentricity` |
the eccentricity of the conic. |

`intercepts` |
the intercepts in the case of parallel lines. |

`points` |
the coordinates of the points used to plot the conic. |

The `points`

component is returned only if the *type* option is
equal to `n`

and if the conic is non-degenerate. In that case, nothing is
drawn.

Bernard Desgraupes

bernard.desgraupes@u-paris10.fr

University of Paris Ouest - Nanterre

Lab Modal'X

`conicAsymptotes`

,
`conicAxes`

,
`conicCenter`

,
`conicMatrix`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | ```
# Ellipse
# -------
# Equation: 2*x_1^2 + 2*x_1*x_2 + 2*x_2^2 - 20*x_1 - 28*x_2 + 10 = 0
v <- c(2,2,2,-20,-28,10)
conicPlot(v)
v[6] <- 20
conicPlot(v, type='p', col="red", add=TRUE)
# Symmetric matrix
m <- rbind( c(5, -3, -21),
c(-3, 5, -19),
c(-21, -19, 93) )
conicPlot(m)
# Hyperbola
# ---------
# Equation: 2*x_1^2 + 2*x_1*x_2 - 2*x_2^2 - 20*x_1 + 20*x_2 + 10 = 0
v <- c(2,2,-2,-20,20,10)
conicPlot(v, center=TRUE, sym.axes=TRUE, asp=1)
conicPlot(v, asymptote=TRUE, as.col="grey30", as.lty=2,
sym.axes=TRUE, ax.col="red", ax.lty=6, col="blue", asp=1)
# Parabola
# --------
# Equation: 4*x_1^2 + 4*x_1*x_2 + 1*x_2^2 + 20*x_1 + 20*x_2 + 20 = 0
v <- c(4,4,1,20,20,20)
conicPlot(v, sym.axes=TRUE, ax.lty=2, asp=1)
# Degenerate conics
# -----------------
# Intersecting lines
# Equation: x_1^2 - 2*x_1*x_2 - 8*x_2^2 - 2*x_1 + 14*x_2 - 3 = 0
v <- c(1,-2,-8,-2,14,-3)
conicPlot(v)
# Parallel lines
# Equation: x_1^2 - 2*x_1*x_2 + x_2^2 + 4*x_1 - 4*x_2 + 3 = 0
v <- c(1,-2,1,4,-4,3)
conicPlot(v)
# Coincident lines
# Equation: 4*x_1^2 + 12*x_1*x_2 + 9*x_2^2 - 4*x_1 - 6*x_2 + 1 = 0
v <- c(4,12,9,-4,-6,1)
conicPlot(v)
# Return value
# ------------
v <- c(2,2,2,-20,-28,10)
cp <- conicPlot(v)
cp$kind
cp$vertices
cp$center
cp$axes
cp <- conicPlot(v,type='n')
cp$points
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.