Triangle {PlaneGeometry}R Documentation

R6 class representing a triangle

Description

A triangle has three vertices. They are named A, B, C.

Active bindings

A

get or set the vertex A

B

get or set the vertex B

C

get or set the vertex C

Methods

Public methods


Method new()

Create a new Triangle object.

Usage
Triangle$new(A, B, C)
Arguments
A, B, C

vertices

Returns

A new Triangle object.

Examples
t <- Triangle$new(c(0,0), c(1,0), c(1,1))
t
t$C
t$C <- c(2,2)
t

Method print()

Show instance of a triangle object

Usage
Triangle$print(...)
Arguments
...

ignored

Examples
Triangle$new(c(0,0), c(1,0), c(1,1))

Method flatness()

Flatness of the triangle.

Usage
Triangle$flatness()
Returns

A number between 0 and 1. A triangle is flat when its flatness is 1.


Method a()

Length of the side BC.

Usage
Triangle$a()

Method b()

Length of the side AC.

Usage
Triangle$b()

Method c()

Length of the side AB.

Usage
Triangle$c()

Method edges()

The lengths of the sides of the triangle.

Usage
Triangle$edges()
Returns

A named numeric vector.


Method perimeter()

Perimeter of the triangle.

Usage
Triangle$perimeter()
Returns

The perimeter of the triangle.


Method orientation()

Determine the orientation of the triangle.

Usage
Triangle$orientation()
Returns

An integer: 1 for counterclockwise, -1 for clockwise, 0 for collinear.


Method contains()

Determine whether a point lies inside the reference triangle.

Usage
Triangle$contains(M)
Arguments
M

a point


Method isAcute()

Determines whether the reference triangle is acute.

Usage
Triangle$isAcute()
Returns

'TRUE' if the triangle is acute (or right), 'FALSE' otherwise.


Method angleA()

Angle at the vertex A.

Usage
Triangle$angleA()
Returns

The angle at the vertex A in radians.


Method angleB()

Angle at the vertex B.

Usage
Triangle$angleB()
Returns

The angle at the vertex B in radians.


Method angleC()

Angle at the vertex C.

Usage
Triangle$angleC()
Returns

The angle at the vertex C in radians.


Method angles()

The three angles of the triangle.

Usage
Triangle$angles()
Returns

A named vector containing the values of the angles in radians.


Method X175()

Isoperimetric point, also known as the X(175) triangle center; this is the center of the outer Soddy circle.

Usage
Triangle$X175()

Method VeldkampIsoperimetricPoint()

Isoperimetric point in the sense of Veldkamp.

Usage
Triangle$VeldkampIsoperimetricPoint()
Returns

The isoperimetric point in the sense of Veldkamp, if it exists. Otherwise, returns 'NULL'.


Method centroid()

Centroid.

Usage
Triangle$centroid()

Method orthocenter()

Orthocenter.

Usage
Triangle$orthocenter()

Method area()

Area of the triangle.

Usage
Triangle$area()

Method incircle()

Incircle of the triangle.

Usage
Triangle$incircle()
Returns

A Circle object.


Method inradius()

Inradius of the reference triangle.

Usage
Triangle$inradius()

Method incenter()

Incenter of the reference triangle.

Usage
Triangle$incenter()

Method excircles()

Excircles of the triangle.

Usage
Triangle$excircles()
Returns

A list with the three excircles, Circle objects.


Method excentralTriangle()

Excentral triangle of the reference triangle.

Usage
Triangle$excentralTriangle()
Returns

A Triangle object.


Method BevanPoint()

Bevan point. This is the circumcenter of the excentral triangle.

Usage
Triangle$BevanPoint()

Method medialTriangle()

Medial triangle. Its vertices are the mid-points of the sides of the reference triangle.

Usage
Triangle$medialTriangle()

Method orthicTriangle()

Orthic triangle. Its vertices are the feet of the altitudes of the reference triangle.

Usage
Triangle$orthicTriangle()

Method incentralTriangle()

Incentral triangle.

Usage
Triangle$incentralTriangle()
Details

It is the triangle whose vertices are the intersections of the reference triangle's angle bisectors with the respective opposite sides.

Returns

A Triangle object.


Method NagelTriangle()

Nagel triangle (or extouch triangle) of the reference triangle.

Usage
Triangle$NagelTriangle(NagelPoint = FALSE)
Arguments
NagelPoint

logical, whether to return the Nagel point as attribute

Returns

A Triangle object.

Examples
t <- Triangle$new(c(0,-2), c(0.5,1), c(3,0.6))
lineAB <- Line$new(t$A, t$B)
lineAC <- Line$new(t$A, t$C)
lineBC <- Line$new(t$B, t$C)
NagelTriangle <- t$NagelTriangle(NagelPoint = TRUE)
NagelPoint <- attr(NagelTriangle, "Nagel point")
excircles <- t$excircles()
opar <- par(mar = c(0,0,0,0))
plot(0, 0, type="n", asp = 1, xlim = c(-1,5), ylim = c(-3,3),
     xlab = NA, ylab = NA, axes = FALSE)
draw(t, lwd = 2)
draw(lineAB); draw(lineAC); draw(lineBC)
draw(excircles$A, border = "orange")
draw(excircles$B, border = "orange")
draw(excircles$C, border = "orange")
draw(NagelTriangle, lwd = 2, col = "red")
draw(Line$new(t$A, NagelTriangle$A, FALSE, FALSE), col = "blue")
draw(Line$new(t$B, NagelTriangle$B, FALSE, FALSE), col = "blue")
draw(Line$new(t$C, NagelTriangle$C, FALSE, FALSE), col = "blue")
points(rbind(NagelPoint), pch = 19)
par(opar)

Method NagelPoint()

Nagel point of the triangle.

Usage
Triangle$NagelPoint()

Method GergonneTriangle()

Gergonne triangle of the reference triangle.

Usage
Triangle$GergonneTriangle(GergonnePoint = FALSE)
Arguments
GergonnePoint

logical, whether to return the Gergonne point as an attribute

Details

The Gergonne triangle is also known as the intouch triangle or the contact triangle. This is the triangle made of the three tangency points of the incircle.

Returns

A Triangle object.


Method GergonnePoint()

Gergonne point of the reference triangle.

Usage
Triangle$GergonnePoint()

Method tangentialTriangle()

Tangential triangle of the reference triangle. This is the triangle formed by the lines tangent to the circumcircle of the reference triangle at its vertices. It does not exist for a right triangle.

Usage
Triangle$tangentialTriangle()
Returns

A Triangle object.


Method symmedialTriangle()

Symmedial triangle of the reference triangle.

Usage
Triangle$symmedialTriangle()
Returns

A Triangle object.

Examples
t <- Triangle$new(c(0,-2), c(0.5,1), c(3,0.6))
symt <- t$symmedialTriangle()
symmedianA <- Line$new(t$A, symt$A, FALSE, FALSE)
symmedianB <- Line$new(t$B, symt$B, FALSE, FALSE)
symmedianC <- Line$new(t$C, symt$C, FALSE, FALSE)
K <- t$symmedianPoint()
opar <- par(mar = c(0,0,0,0))
plot(NULL, asp = 1, xlim = c(-1,5), ylim = c(-3,3),
     xlab = NA, ylab = NA, axes = FALSE)
draw(t, lwd = 2)
draw(symmedianA, lwd = 2, col = "blue")
draw(symmedianB, lwd = 2, col = "blue")
draw(symmedianC, lwd = 2, col = "blue")
points(rbind(K), pch = 19, col = "red")
par(opar)

Method symmedianPoint()

Symmedian point of the reference triangle.

Usage
Triangle$symmedianPoint()
Returns

A point.


Method circumcircle()

Circumcircle of the reference triangle.

Usage
Triangle$circumcircle()
Returns

A Circle object.


Method circumcenter()

Circumcenter of the reference triangle.

Usage
Triangle$circumcenter()

Method circumradius()

Circumradius of the reference triangle.

Usage
Triangle$circumradius()

Method BrocardCircle()

The Brocard circle of the reference triangle (also known as the seven-point circle).

Usage
Triangle$BrocardCircle()
Returns

A Circle object.


Method BrocardPoints()

Brocard points of the reference triangle.

Usage
Triangle$BrocardPoints()
Returns

A list of two points, the first Brocard point and the second Brocard point.


Method LemoineCircleI()

The first Lemoine circle of the reference triangle.

Usage
Triangle$LemoineCircleI()
Returns

A Circle object.


Method LemoineCircleII()

The second Lemoine circle of the reference triangle (also known as the cosine circle)

Usage
Triangle$LemoineCircleII()
Returns

A Circle object.


Method LemoineTriangle()

The Lemoine triangle of the reference triangle.

Usage
Triangle$LemoineTriangle()
Returns

A Triangle object.


Method LemoineCircleIII()

The third Lemoine circle of the reference triangle.

Usage
Triangle$LemoineCircleIII()
Returns

A Circle object.


Method ParryCircle()

Parry circle of the reference triangle.

Usage
Triangle$ParryCircle()
Returns

A Circle object.


Method outerSoddyCircle()

Soddy outer circle of the reference triangle.

Usage
Triangle$outerSoddyCircle()
Returns

A Circle object.


Method pedalTriangle()

Pedal triangle of a point with respect to the reference triangle. The pedal triangle of a point P is the triangle whose vertices are the feet of the perpendiculars from P to the sides of the reference triangle.

Usage
Triangle$pedalTriangle(P)
Arguments
P

a point

Returns

A Triangle object.


Method CevianTriangle()

Cevian triangle of a point with respect to the reference triangle.

Usage
Triangle$CevianTriangle(P)
Arguments
P

a point

Returns

A Triangle object.


Method MalfattiCircles()

Malfatti circles of the triangle.

Usage
Triangle$MalfattiCircles(tangencyPoints = FALSE)
Arguments
tangencyPoints

logical, whether to retourn the tangency points of the Malfatti circles as an attribute.

Returns

A list with the three Malfatti circles, Circle objects.

Examples
t <- Triangle$new(c(0,0), c(2,0.5), c(1.5,2))
Mcircles <- t$MalfattiCircles(TRUE)
plot(NULL, asp = 1, xlim = c(0,2.5), ylim = c(0,2.5),
     xlab = NA, ylab = NA)
grid()
draw(t, col = "blue", lwd = 2)
invisible(lapply(Mcircles, draw, col = "green", border = "red"))
invisible(lapply(attr(Mcircles, "tangencyPoints"), function(P){
  points(P[1], P[2], pch = 19)
}))

Method AjimaMalfatti1()

First Ajima-Malfatti point of the triangle.

Usage
Triangle$AjimaMalfatti1()

Method AjimaMalfatti2()

Second Ajima-Malfatti point of the triangle.

Usage
Triangle$AjimaMalfatti2()

Method equalDetourPoint()

Equal detour point of the triangle.

Usage
Triangle$equalDetourPoint(detour = FALSE)
Arguments
detour

logical, whether to return the detour as an attribute

Details

Also known as the X(176) triangle center.


Method trilinearToPoint()

Point given by trilinear coordinates.

Usage
Triangle$trilinearToPoint(x, y, z)
Arguments
x, y, z

trilinear coordinates

Returns

The point with trilinear coordinates x:y:z with respect to the reference triangle.

Examples
t <- Triangle$new(c(0,0), c(2,1), c(5,7))
incircle <- t$incircle()
t$trilinearToPoint(1, 1, 1)
incircle$center

Method pointToTrilinear()

Give the trilinear coordinates of a point with respect to the reference triangle.

Usage
Triangle$pointToTrilinear(P)
Arguments
P

a point

Returns

The trilinear coordinates, a numeric vector of length 3.


Method isogonalConjugate()

Isogonal conjugate of a point with respect to the reference triangle.

Usage
Triangle$isogonalConjugate(P)
Arguments
P

a point

Returns

A point, the isogonal conjugate of P.


Method rotate()

Rotate the triangle.

Usage
Triangle$rotate(alpha, O, degrees = TRUE)
Arguments
alpha

angle of rotation

O

center of rotation

degrees

logical, whether alpha is given in degrees

Returns

A Triangle object.


Method translate()

Translate the triangle.

Usage
Triangle$translate(v)
Arguments
v

the vector of translation

Returns

A Triangle object.


Method SteinerEllipse()

The Steiner ellipse (or circumellipse) of the reference triangle. This is the ellipse passing through the three vertices of the triangle and centered at the centroid of the triangle.

Usage
Triangle$SteinerEllipse()
Returns

An Ellipse object.

Examples
t <- Triangle$new(c(0,0), c(2,0.5), c(1.5,2))
ell <- t$SteinerEllipse()
plot(NULL, asp = 1, xlim = c(0,2.5), ylim = c(-0.7,2.4),
     xlab = NA, ylab = NA)
draw(t, col = "blue", lwd = 2)
draw(ell, border = "red", lwd =2)

Method SteinerInellipse()

The Steiner inellipse (or midpoint ellipse) of the reference triangle. This is the ellipse tangent to the sides of the triangle at their midpoints, and centered at the centroid of the triangle.

Usage
Triangle$SteinerInellipse()
Returns

An Ellipse object.

Examples
t <- Triangle$new(c(0,0), c(2,0.5), c(1.5,2))
ell <- t$SteinerInellipse()
plot(NULL, asp = 1, xlim = c(0,2.5), ylim = c(-0.1,2.4),
     xlab = NA, ylab = NA)
draw(t, col = "blue", lwd = 2)
draw(ell, border = "red", lwd =2)

Method MandartInellipse()

The Mandart inellipse of the reference triangle. This is the unique ellipse tangent to the triangle's sides at the contact points of its excircles

Usage
Triangle$MandartInellipse()
Returns

An Ellipse object.


Method randomPoints()

Random points on or in the reference triangle.

Usage
Triangle$randomPoints(n, where = "in")
Arguments
n

an integer, the desired number of points

where

"in" to generate inside the triangle, "on" to generate on the sides of the triangle

Returns

The generated points in a two columns matrix with n rows.


Method hexylTriangle()

Hexyl triangle.

Usage
Triangle$hexylTriangle()

Method plot()

Plot a Triangle object.

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

Boolean, whether to add the plot to the current plot

...

named arguments passed to polygon

Returns

Nothing, called for plotting only.

Examples
trgl <- Triangle$new(c(0, 0), c(1, 0), c(0.5, sqrt(3)/2))
trgl$plot(col = "yellow", border = "red")

Method clone()

The objects of this class are cloneable with this method.

Usage
Triangle$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Note

The Steiner ellipse is also the smallest area ellipse which passes through the vertices of the triangle, and thus can be obtained with the function EllipseFromThreeBoundaryPoints. We can also note that the major axis of the Steiner ellipse is the Deming least squares line of the three triangle vertices.

See Also

TriangleThreeLines to define a triangle by three lines.

Examples

# incircle and excircles
A <- c(0,0); B <- c(1,2); C <- c(3.5,1)
t <- Triangle$new(A, B, C)
incircle <- t$incircle()
excircles <- t$excircles()
JA <- excircles$A$center
JB <- excircles$B$center
JC <- excircles$C$center
JAJBJC <- Triangle$new(JA, JB, JC)
A_JA <- Line$new(A, JA, FALSE, FALSE)
B_JB <- Line$new(B, JB, FALSE, FALSE)
C_JC <- Line$new(C, JC, FALSE, FALSE)
opar <- par(mar = c(0,0,0,0))
plot(NULL, asp = 1, xlim = c(0,6), ylim = c(-4,4),
     xlab = NA, ylab = NA, axes = FALSE)
draw(t, lwd = 2)
draw(incircle, border = "orange")
draw(excircles$A); draw(excircles$B); draw(excircles$C)
draw(JAJBJC, col = "blue")
draw(A_JA, col = "green")
draw(B_JB, col = "green")
draw(C_JC, col = "green")
par(opar)


## ------------------------------------------------
## Method `Triangle$new`
## ------------------------------------------------

t <- Triangle$new(c(0,0), c(1,0), c(1,1))
t
t$C
t$C <- c(2,2)
t

## ------------------------------------------------
## Method `Triangle$print`
## ------------------------------------------------

Triangle$new(c(0,0), c(1,0), c(1,1))

## ------------------------------------------------
## Method `Triangle$NagelTriangle`
## ------------------------------------------------

t <- Triangle$new(c(0,-2), c(0.5,1), c(3,0.6))
lineAB <- Line$new(t$A, t$B)
lineAC <- Line$new(t$A, t$C)
lineBC <- Line$new(t$B, t$C)
NagelTriangle <- t$NagelTriangle(NagelPoint = TRUE)
NagelPoint <- attr(NagelTriangle, "Nagel point")
excircles <- t$excircles()
opar <- par(mar = c(0,0,0,0))
plot(0, 0, type="n", asp = 1, xlim = c(-1,5), ylim = c(-3,3),
     xlab = NA, ylab = NA, axes = FALSE)
draw(t, lwd = 2)
draw(lineAB); draw(lineAC); draw(lineBC)
draw(excircles$A, border = "orange")
draw(excircles$B, border = "orange")
draw(excircles$C, border = "orange")
draw(NagelTriangle, lwd = 2, col = "red")
draw(Line$new(t$A, NagelTriangle$A, FALSE, FALSE), col = "blue")
draw(Line$new(t$B, NagelTriangle$B, FALSE, FALSE), col = "blue")
draw(Line$new(t$C, NagelTriangle$C, FALSE, FALSE), col = "blue")
points(rbind(NagelPoint), pch = 19)
par(opar)

## ------------------------------------------------
## Method `Triangle$symmedialTriangle`
## ------------------------------------------------

t <- Triangle$new(c(0,-2), c(0.5,1), c(3,0.6))
symt <- t$symmedialTriangle()
symmedianA <- Line$new(t$A, symt$A, FALSE, FALSE)
symmedianB <- Line$new(t$B, symt$B, FALSE, FALSE)
symmedianC <- Line$new(t$C, symt$C, FALSE, FALSE)
K <- t$symmedianPoint()
opar <- par(mar = c(0,0,0,0))
plot(NULL, asp = 1, xlim = c(-1,5), ylim = c(-3,3),
     xlab = NA, ylab = NA, axes = FALSE)
draw(t, lwd = 2)
draw(symmedianA, lwd = 2, col = "blue")
draw(symmedianB, lwd = 2, col = "blue")
draw(symmedianC, lwd = 2, col = "blue")
points(rbind(K), pch = 19, col = "red")
par(opar)

## ------------------------------------------------
## Method `Triangle$MalfattiCircles`
## ------------------------------------------------

t <- Triangle$new(c(0,0), c(2,0.5), c(1.5,2))
Mcircles <- t$MalfattiCircles(TRUE)
plot(NULL, asp = 1, xlim = c(0,2.5), ylim = c(0,2.5),
     xlab = NA, ylab = NA)
grid()
draw(t, col = "blue", lwd = 2)
invisible(lapply(Mcircles, draw, col = "green", border = "red"))
invisible(lapply(attr(Mcircles, "tangencyPoints"), function(P){
  points(P[1], P[2], pch = 19)
}))

## ------------------------------------------------
## Method `Triangle$trilinearToPoint`
## ------------------------------------------------

t <- Triangle$new(c(0,0), c(2,1), c(5,7))
incircle <- t$incircle()
t$trilinearToPoint(1, 1, 1)
incircle$center

## ------------------------------------------------
## Method `Triangle$SteinerEllipse`
## ------------------------------------------------

t <- Triangle$new(c(0,0), c(2,0.5), c(1.5,2))
ell <- t$SteinerEllipse()
plot(NULL, asp = 1, xlim = c(0,2.5), ylim = c(-0.7,2.4),
     xlab = NA, ylab = NA)
draw(t, col = "blue", lwd = 2)
draw(ell, border = "red", lwd =2)

## ------------------------------------------------
## Method `Triangle$SteinerInellipse`
## ------------------------------------------------

t <- Triangle$new(c(0,0), c(2,0.5), c(1.5,2))
ell <- t$SteinerInellipse()
plot(NULL, asp = 1, xlim = c(0,2.5), ylim = c(-0.1,2.4),
     xlab = NA, ylab = NA)
draw(t, col = "blue", lwd = 2)
draw(ell, border = "red", lwd =2)

## ------------------------------------------------
## Method `Triangle$plot`
## ------------------------------------------------

trgl <- Triangle$new(c(0, 0), c(1, 0), c(0.5, sqrt(3)/2))
trgl$plot(col = "yellow", border = "red")

[Package PlaneGeometry version 1.6.0 Index]