https://github.com/stla/planegeometry
Plane geometry with R
https://github.com/stla/planegeometry
geometry r
Last synced: about 1 year ago
JSON representation
Plane geometry with R
- Host: GitHub
- URL: https://github.com/stla/planegeometry
- Owner: stla
- Created: 2020-01-18T18:29:18.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-08-07T11:40:28.000Z (almost 3 years ago)
- Last Synced: 2025-03-28T03:24:29.631Z (about 1 year ago)
- Topics: geometry, r
- Language: R
- Size: 8.41 MB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: NEWS.md
Awesome Lists containing this project
README
# PlaneGeometry: plane geometry with R
[](https://github.com/stla/PlaneGeometry/actions/workflows/R-CMD-check.yaml)
___
```r
library(PlaneGeometry)
# starting triangle
tr <- Triangle$new(c(0,0), c(4,1), c(3,3))
# excircles
excircles <- tr$excircles()
JA <- excircles[["A"]]$center
JB <- excircles[["B"]]$center
JC <- excircles[["C"]]$center
# hexyl triangle
ht <- tr$hexylTriangle()
A <- ht$A; B <- ht$B; C <- ht$C
opar <- par(mar = c(0, 0, 0, 0))
plot(NULL, type = "n", asp = 1, xlim = c(-3, 6), ylim = c(-4, 6),
xlab = NA, ylab = NA, axes = FALSE)
# draw reference triangle
draw(tr, lwd = 2, col = "blue")
# draw excircles and their center
draw(excircles[["A"]]); draw(excircles[["B"]]); draw(excircles[["C"]])
points(rbind(JA, JB, JC), pch = 19, col = "green")
# draw hexyl triangle
draw(ht, lwd = 2, col = "red")
## the vertices of the hexyl triangle and the excenters form an hexagon
## whose opposite sides are parallel
polygon(rbind(A, JC, B, JA, C, JB), border = "green", lwd = 2)
one_side <- Line$new(A, JC)
opposite_side <- Line$new(C, JA)
one_side$isParallel(opposite_side)
# TRUE
## the vertices of this hexagon lie on an ellipse
ell <- EllipseFromFivePoints(A, JC, B, JA, C)
draw(ell, lwd = 2)
par(opar)
```

___
See more examples in [the vignette](https://cran.r-project.org/web/packages/PlaneGeometry/vignettes/examples.html).