Polyhedra Database

A polyhedra database scraped from various sources as R6 objects and 'rgl' visualizing capabilities.


This package is a curation made based on the poly package found on http://www.netlib.org/polyhedra/ (Original Help message), and the polyhedra database found on http://dmccooey.com/polyhedra, both of which provide polyhedra databases on its own format. As such, Rpolyhedra provides with the following:

  1. A module to scrape the polyhedra for the different sources found with features for incremental correction of issues found and to be found in scraping process.
  2. A database of the scraped polyhedra.
  3. An R6 polyhedron representation with 'rgl' package visualizing capabilities.
Release Usage Development
minimal R version Travis
CRAN codecov
Project Status: Active – The project has reached a stable, usable state and is being actively developed.

How to get started

install.packages("Rpolyhedra")

How to get started (Development version)

Install the R package using the following commands on the R console:

devtools::install_github("ropensci/Rpolyhedra", build_opts = NULL)
library(Rpolyhedra)
# if want to switch to fullDB in user filespace, it will download the full database
switchToFullDatabase()

A simple example of 5 regular polyhedra

To get started execute the following commands:

# 0.  Load libraries
library(rgl)
library(dplyr)
library(Rpolyhedra)
# 1.  Obtain 5 regular solids
polyhedra.2.draw <- getAvailablePolyhedra(source = "netlib")
polyhedra.2.draw <- polyhedra.2.draw %>%
                        filter(scraped.name %in%
                            c("tetrahedron", "octahedron", "cube",
                               "icosahedron", "dodecahedron"))
 
# 2. Setup colors and scales
n <- nrow(polyhedra.2.draw)
polyhedron.colors <- rainbow(n)
polyhedron.scale <- 5
 
# 3. open and setup RGL window
open3d()
par3d(FOV = 1)
rgl.bg( sphere =FALSE, fogtype = "none", color=c("black"))
rgl.viewpoint(theta = 0, phi=0, zoom=0.8, fov=1)
 
# 4. for each polyhedron, setup rotation, position and render
for (i in seq_len(n)) {
  # Obtain polyhedron
  polyhedron.row <- polyhedra.2.draw[i,]
  polyhedron.name <- polyhedron.row$scraped.name
  polyhedron <- getPolyhedron(source = polyhedron.row$source, polyhedron.name)
 
  # Setup angles, position into transformationMatrix
  current.angle <- i/n * 2 * pi
  tm <- rotationMatrix(current.angle, 1, 0, 0)
  x.pos <- round(polyhedron.scale * sin(current.angle), 2)
  y.pos <- round(polyhedron.scale * cos(current.angle), 2)
  tm <- tm %*% translationMatrix(x.pos, y.pos, 0)
 
  # Render
  print(paste("Drawing ", polyhedron.name, " rotated ", round(current.angle, 2),
              " in (1,0,0) axis. Translated to (", x.pos, ",", y.pos, ",0)",
              " with color ", polyhedron.colors[i], sep = ""))
  shape.rgl <- polyhedron$getRGLModel(transformation.matrix = tm)
  shade3d(shape.rgl, color = polyhedron.colors[i])
}
 

sources

netlib

Includes 142 polyhedra definitions. The PHD format was created to describe the geometric polyhedron definitions derived mathematically by Andrew Hume and by the Kaleido program of Zvi Har'El.

PHD files were generated using poly2 library (no longer maintained). Although the code is available, specific programming skills are required to run it.

PHD files can be found in extdata/www.netlib.org/polyhedra/index.html

dmccooey

Includes 767 polyhedra definitions. The polyhedra database built by David Mccooey has an open format which has been scraped to feed RPolyhedra database

dmccooey files can be found in extdata/dmccooey.com/polyhedra/

Troubleshooting

devtools

Ubuntu

apt-get install libcurl4-openssl-dev

Windows

run end user CRAN version

macOS brew

brew install openssl

After, in R:

install.packages("devtools")

rgl

Ubuntu

sudo apt-get install r-cran-rgl

Please note that the 'Rpolyhedra' project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

ropensci_footer

News

Rpolyhedra 0.4.2

First version published using devtools::release() on rOpenSci.org.

MINOR IMPROVEMENTS

  • Calculates and normalizes polyhedra size using geometry::convhulln instead of bounding box

BUG FIXES

  • A polyhedron now applies internal transformation matrix

Rpolyhedra 0.4.1

First version published on rOpenSci.org.

MINOR IMPROVEMENTS

  • Complies with all the prerequisites of rOpenSci and applies the suggestions made by rOpenSci reviwers.
  • Fixes a test that writes on user space.
  • Integrates with codecov.io, which allows for better test coverage.
  • Updated examples.

Rpolyhedra 0.4.0

NEW FEATURES

  • Rpolyhedra can export polyhedra definitions as XML.

Rpolyhedra 0.3.0

NEW FEATURES

  • Rpolyhedra now has a new database format based on ascii RDSs, which are meant to use less memory, for example when used in a Shiny App.
  • Rpolyhedra now uses a transformation matrix for general polyhedra manipulation.

MINOR IMPROVEMENTS

  • Applied suggestions from rOpenSci onboarding process.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("Rpolyhedra")

0.4.2 by Alejandro Baranek, 6 months ago


https://github.com/ropensci/Rpolyhedra


Report a bug at https://github.com/ropensci/Rpolyhedra/issues


Browse source code at https://github.com/cran/Rpolyhedra


Authors: Alejandro Baranek [aut, com, cre, cph] , Leonardo Belen [aut, com, cph] , Barret Schloerke [rev] , Lijia Yu [rev]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports R6, geometry, rgl, stringr, dplyr, XML, digest, testthat, futile.logger, git2r

Suggests knitr, rmarkdown, covr


See at CRAN