Hyperbola: R6 class representing a hyperbola

HyperbolaR Documentation

R6 class representing a hyperbola

Description

A hyperbola is given by two intersecting asymptotes, named L1 and L2, and a point on this hyperbola, named M.

Active bindings

L1

get or set the asymptote L1

L2

get or set the asymptote L2

M

get or set the point M

Methods

Public methods


Method new()

Create a new Hyperbola object.

Usage
Hyperbola$new(L1, L2, M)
Arguments
L1, L2

two intersecting lines given as Line objects, the asymptotes

M

a point on the hyperbola

Returns

A new Hyperbola object.


Method center()

Center of the hyperbola.

Usage
Hyperbola$center()
Returns

The center of the hyperbola, i.e. the point where the two asymptotes meet each other.


Method OAB()

Parametric equation O \pm cosh(t) A + sinh(t) B representing the hyperbola.

Usage
Hyperbola$OAB()
Returns

The point O and the two vectors A and B in a list.

Examples
L1 <- LineFromInterceptAndSlope(0, 2)
L2 <- LineFromInterceptAndSlope(-2, -0.5)
M <- c(4, 3)
hyperbola <- Hyperbola$new(L1, L2, M)
hyperbola$OAB()

Method vertices()

Vertices of the hyperbola.

Usage
Hyperbola$vertices()
Returns

The two vertices V1 and V2 in a list.


Method abce()

The numbers a (semi-major axis, i.e. distance from center to vertex), b (semi-minor axis), c (linear eccentricity) and e (eccentricity) associated to the hyperbola.

Usage
Hyperbola$abce()
Returns

The four numbers a, b, c and e in a list.


Method foci()

Foci of the hyperbola.

Usage
Hyperbola$foci()
Returns

The two foci F1 and F2 in a list.


Method plot()

Plot hyperbola.

Usage
Hyperbola$plot(add = FALSE, ...)
Arguments
add

Boolean, whether to add this plot to the current plot

...

named arguments passed to lines

Returns

Nothing, called for plotting.

Examples
L1 <- LineFromInterceptAndSlope(0, 2)
L2 <- LineFromInterceptAndSlope(-2, -0.5)
M <- c(4, 3)
hyperbola <- Hyperbola$new(L1, L2, M)
plot(hyperbola, lwd = 2)
points(t(M), pch = 19, col = "blue")
O <- hyperbola$center()
points(t(O), pch = 19)
draw(L1, col = "red")
draw(L2, col = "red")
vertices <- hyperbola$vertices()
points(rbind(vertices$V1, vertices$V2), pch = 19)
majorAxis <- Line$new(vertices$V1, vertices$V2)
draw(majorAxis, lty = "dashed")
foci <- hyperbola$foci()
points(rbind(foci$F1, foci$F2), pch = 19, col = "green")

Method includes()

Whether a point belongs to the hyperbola.

Usage
Hyperbola$includes(P)
Arguments
P

a point

Returns

A Boolean value.

Examples
L1 <- LineFromInterceptAndSlope(0, 2)
L2 <- LineFromInterceptAndSlope(-2, -0.5)
M <- c(4, 3)
hyperbola <- Hyperbola$new(L1, L2, M)
hyperbola$includes(M)

Method equation()

Implicit quadratic equation of the hyperbola Axxx2 + 2Axyxy + Ayyy2 + 2Bxx + 2Byy + C = 0

Usage
Hyperbola$equation()
Returns

The coefficients of the equation in a named list.

Examples
L1 <- LineFromInterceptAndSlope(0, 2)
L2 <- LineFromInterceptAndSlope(-2, -0.5)
M <- c(4, 3)
hyperbola <- Hyperbola$new(L1, L2, M)
eq <- hyperbola$equation()
x <- M[1]; y <- M[2]
with(eq, Axx*x^2 + 2*Axy*x*y + Ayy*y^2 + 2*Bx*x + 2*By*y + C)
V1 <- hyperbola$vertices()$V1
x <- V1[1]; y <- V1[2]
with(eq, Axx*x^2 + 2*Axy*x*y + Ayy*y^2 + 2*Bx*x + 2*By*y + C)

Method clone()

The objects of this class are cloneable with this method.

Usage
Hyperbola$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples


## ------------------------------------------------
## Method `Hyperbola$OAB`
## ------------------------------------------------

L1 <- LineFromInterceptAndSlope(0, 2)
L2 <- LineFromInterceptAndSlope(-2, -0.5)
M <- c(4, 3)
hyperbola <- Hyperbola$new(L1, L2, M)
hyperbola$OAB()

## ------------------------------------------------
## Method `Hyperbola$plot`
## ------------------------------------------------

L1 <- LineFromInterceptAndSlope(0, 2)
L2 <- LineFromInterceptAndSlope(-2, -0.5)
M <- c(4, 3)
hyperbola <- Hyperbola$new(L1, L2, M)
plot(hyperbola, lwd = 2)
points(t(M), pch = 19, col = "blue")
O <- hyperbola$center()
points(t(O), pch = 19)
draw(L1, col = "red")
draw(L2, col = "red")
vertices <- hyperbola$vertices()
points(rbind(vertices$V1, vertices$V2), pch = 19)
majorAxis <- Line$new(vertices$V1, vertices$V2)
draw(majorAxis, lty = "dashed")
foci <- hyperbola$foci()
points(rbind(foci$F1, foci$F2), pch = 19, col = "green")

## ------------------------------------------------
## Method `Hyperbola$includes`
## ------------------------------------------------

L1 <- LineFromInterceptAndSlope(0, 2)
L2 <- LineFromInterceptAndSlope(-2, -0.5)
M <- c(4, 3)
hyperbola <- Hyperbola$new(L1, L2, M)
hyperbola$includes(M)

## ------------------------------------------------
## Method `Hyperbola$equation`
## ------------------------------------------------

L1 <- LineFromInterceptAndSlope(0, 2)
L2 <- LineFromInterceptAndSlope(-2, -0.5)
M <- c(4, 3)
hyperbola <- Hyperbola$new(L1, L2, M)
eq <- hyperbola$equation()
x <- M[1]; y <- M[2]
with(eq, Axx*x^2 + 2*Axy*x*y + Ayy*y^2 + 2*Bx*x + 2*By*y + C)
V1 <- hyperbola$vertices()$V1
x <- V1[1]; y <- V1[2]
with(eq, Axx*x^2 + 2*Axy*x*y + Ayy*y^2 + 2*Bx*x + 2*By*y + C)

PlaneGeometry documentation built on Aug. 10, 2023, 1:09 a.m.