conicPlot: Plot a conic

Description Usage Arguments Details Value Author(s) See Also Examples

Description

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

Usage

1
2
3
4
5
    conicPlot(x, type='l', npoints=100, 
            sym.axes=FALSE, center=FALSE, asymptotes=FALSE, 
            add=FALSE, xlim=NULL, ylim=NULL, 
            ax.lty=1, ax.col=palette()[1], 
            as.lty=1, as.col=palette()[1], ...)

Arguments

x

a 6-length vector or a symmetric 3x3 matrix

type

(character) the type of plot to draw (same meaning as with the plot function)

npoints

(numeric) number of points to draw

sym.axes

(logical) if TRUE, display the axes of the conic

center

(logical) if TRUE, display the center of the conic (if any)

asymptotes

(logical) if TRUE, display the asymptotes (hyperbolas)

add

(logical) if TRUE, plot over the current graphical device

xlim

(vector) interval for the x-coordinate

ylim

(vector) interval for the y-coordinate

ax.lty

(character or numeric) line type of the axes

ax.col

(character or numeric) color of the axes

as.lty

(character or numeric) line type of the asymptotes

as.col

(character or numeric) color of the asymptotes

...

other parameters passed to the plot function

Details

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.

Value

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: "ellipse", "hyperbola", "parabola", or "lines".

axes

the symmetry axes. See also the function conicAxes.

center

the center of the conic. See also the function conicCenter.

asymptotes

the slopes of the asymptotes. See also the function conicAsymptotes.

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.

Author(s)

Bernard Desgraupes
bernard.desgraupes@u-paris10.fr
University of Paris Ouest - Nanterre
Lab Modal'X

See Also

conicAsymptotes, conicAxes, conicCenter, conicMatrix

Examples

 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

Example output

[1] "ellipse"
$x
[1]  5.958114 -4.855655 -1.958114  8.855655

$y
[1]  9.9581140 12.8556546  2.0418860 -0.8556546

[1] 2 6
          [,1]       [,2]
[1,] 0.7071068 -0.7071068
[2,] 0.7071068  0.7071068
                x           y
  [1,]  5.9581140  9.95811403
  [2,]  5.5153326 10.38495755
  [3,]  5.0583961 10.79414440
  [4,]  4.5891446 11.18402692
  [5,]  4.1094675 11.55303519
  [6,]  3.6212963 11.89968335
  [7,]  3.1265967 12.22257556
  [8,]  2.6273607 12.52041166
  [9,]  2.1255986 12.79199237
 [10,]  1.6233307 13.03622412
 [11,]  1.1225795 13.25212347
 [12,]  0.6253614 13.43882109
 [13,]  0.1336785 13.59556520
 [14,] -0.3504894 13.72172465
 [15,] -0.8251927 13.81679144
 [16,] -1.2885200 13.88038276
 [17,] -1.7386055 13.91224257
 [18,] -2.1736370 13.91224257
 [19,] -2.5918628 13.88038276
 [20,] -2.9915987 13.81679144
 [21,] -3.3712352 13.72172465
 [22,] -3.7292437 13.59556520
 [23,] -4.0641825 13.43882109
 [24,] -4.3747030 13.25212347
 [25,] -4.6595548 13.03622412
 [26,] -4.9175910 12.79199237
 [27,] -5.1477724 12.52041166
 [28,] -5.3491723 12.22257556
 [29,] -5.5209796 11.89968335
 [30,] -5.6625027 11.55303519
 [31,] -5.7731715 11.18402692
 [32,] -5.8525405 10.79414440
 [33,] -5.9002901 10.38495755
 [34,] -5.9162281  9.95811403
 [35,] -5.9002901  9.51533258
 [36,] -5.8525405  9.05839612
 [37,] -5.7731715  8.58914459
 [38,] -5.6625027  8.10946748
 [39,] -5.5209796  7.62129629
 [40,] -5.3491723  7.12659672
 [41,] -5.1477724  6.62736073
 [42,] -4.9175910  6.12559859
 [43,] -4.6595548  5.62333070
 [44,] -4.3747030  5.12257953
 [45,] -4.0641825  4.62536142
 [46,] -3.7292437  4.13367850
 [47,] -3.3712352  3.64951059
 [48,] -2.9915987  3.17480728
 [49,] -2.5918628  2.71148002
 [50,] -2.1736370  2.26139447
 [51,] -1.7386055  1.82636296
 [52,] -1.2885200  1.40813722
 [53,] -0.8251927  1.00840128
 [54,] -0.3504894  0.62876476
 [55,]  0.1336785  0.27075630
 [56,]  0.6253614 -0.06418251
 [57,]  1.1225795 -0.37470301
 [58,]  1.6233307 -0.65955482
 [59,]  2.1255986 -0.91759096
 [60,]  2.6273607 -1.14777240
 [61,]  3.1265967 -1.34917228
 [62,]  3.6212963 -1.52097964
 [63,]  4.1094675 -1.66250267
 [64,]  4.5891446 -1.77317150
 [65,]  5.0583961 -1.85254052
 [66,]  5.5153326 -1.90029013
 [67,]  5.9581140 -1.91622806
 [68,]  6.3849576 -1.90029013
 [69,]  6.7941444 -1.85254052
 [70,]  7.1840269 -1.77317150
 [71,]  7.5530352 -1.66250267
 [72,]  7.8996833 -1.52097964
 [73,]  8.2225756 -1.34917228
 [74,]  8.5204117 -1.14777240
 [75,]  8.7919924 -0.91759096
 [76,]  9.0362241 -0.65955482
 [77,]  9.2521235 -0.37470301
 [78,]  9.4388211 -0.06418251
 [79,]  9.5955652  0.27075630
 [80,]  9.7217246  0.62876476
 [81,]  9.8167914  1.00840128
 [82,]  9.8803828  1.40813722
 [83,]  9.9122426  1.82636296
 [84,]  9.9122426  2.26139447
 [85,]  9.8803828  2.71148002
 [86,]  9.8167914  3.17480728
 [87,]  9.7217246  3.64951059
 [88,]  9.5955652  4.13367850
 [89,]  9.4388211  4.62536142
 [90,]  9.2521235  5.12257953
 [91,]  9.0362241  5.62333070
 [92,]  8.7919924  6.12559859
 [93,]  8.5204117  6.62736073
 [94,]  8.2225756  7.12659672
 [95,]  7.8996833  7.62129629
 [96,]  7.5530352  8.10946748
 [97,]  7.1840269  8.58914459
 [98,]  6.7941444  9.05839612
 [99,]  6.3849576  9.51533258
[100,]  5.9581140  9.95811403

conics documentation built on May 2, 2019, 4:15 a.m.