Movatterモバイル変換


[0]ホーム

URL:


Rpolyhedra

DownloadsDownloads

This package is a polyhedra database based on the poly package foundonhttps://netlib.org/polyhedra/ (OriginalHelp message), and the polyhedra definitions found onhttp://dmccooey.com/polyhedra/. As such, Rpolyhedraprovides with the following:

  1. A module to scrape the polyhedra for the different sources foundwith features for incremental correction of issues found and to be foundin scraping process.
  2. A database of the scraped polyhedra.
  3. An R6 polyhedron representation with ‘rgl’ package visualizingcapabilities.
ReleaseUsageDevelopment
minimal R version
R-CMD-check
CRANcodecov
Project Status: Active – The project has reached a stable, usable state and is being actively developed.

Preview

ThroughRpolyhedraexploreryou can navigate the polyhedra database without actually installing Renvironment.

How to get started

install.packages("Rpolyhedra")

How to get started(Development version)

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

devtools::install_github("ropensci/Rpolyhedra",build_opts =NULL)

Loading the database

library(Rpolyhedra)
# if want to switch to fullDB in user filespace, it will ask you for downloading the full database to your home directoryswitchToFullDatabase()

A simple example of 5regular polyhedra

To get started execute the following commands:

# 0.  Load librarieslibrary(knitr)library(rgl)# For foarding webgl output to knitrknit_hooks$set(webgl = hook_webgl)library(dplyr)#>#> Attaching package: 'dplyr'#> The following objects are masked from 'package:stats':#>#>     filter, lag#> The following objects are masked from 'package:base':#>#>     intersect, setdiff, setequal, union
# 1.  Obtain 5 regular solidspolyhedra.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 scalesn<-nrow(polyhedra.2.draw)polyhedron.colors<-rainbow(n)polyhedron.scale<-5
# For interactive RGL window#```{r, render, webgl=TRUE}# 3. open and setup RGL windowopen3d()#> glX#>   1par3d(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 renderfor (iinseq_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)# Renderprint(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])}#> [1] "Drawing tetrahedron rotated 1.26 in (1,0,0) axis. Translated to (4.76,1.55,0) with color #FF0000"#> [1] "Drawing octahedron rotated 2.51 in (1,0,0) axis. Translated to (2.94,-4.05,0) with color #CCFF00"#> [1] "Drawing cube rotated 3.77 in (1,0,0) axis. Translated to (-2.94,-4.05,0) with color #00FF66"#> [1] "Drawing icosahedron rotated 5.03 in (1,0,0) axis. Translated to (-4.76,1.55,0) with color #0066FF"#> [1] "Drawing dodecahedron rotated 6.28 in (1,0,0) axis. Translated to (0,5,0) with color #CC00FF"#rgl::rglwidget()#rgl::rgl.snapshot("man/figures/README-5-polyhedra.png")
5-polyhedra

sources

netlib

Includes 142 polyhedra definitions. The PHD format was created todescribe the geometric polyhedron definitions derived mathematically byAndrew Hume and by the Kaleido program of Zvi Har’El.

PHD files were generated usingpoly2 library (no longermaintained). Although the code is available, specific programming skillsare required to run it.

PHD files can be found inextdata/netlib.org/polyhedra/index.html

dmccooey

Includes 767 polyhedra definitions. Thepolyhedra database built byDavid Mccooey has an open format which has been scraped to feedRpolyhedra database

dmccooey files can be found inextdata/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 aContributorCode of Conduct. Bycontributingto this project, you agree to abide by its terms.

ropensci_footer


[8]ページ先頭

©2009-2025 Movatter.jp