Skip to content

Commit

Permalink
Rprofile
Browse files Browse the repository at this point in the history
  • Loading branch information
stla committed Jul 13, 2023
1 parent ea9b29d commit dc19502
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .Rprofile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
myinstall <- function() {
try(pkgload::unload("cgalMeshes"))
if(rstudioapi::isAvailable()) {
rstudioapi::restartSession(
"devtools::install(quick = TRUE, keep_source = TRUE)"
Expand All @@ -7,12 +8,15 @@ myinstall <- function() {
devtools::install(quick = TRUE, keep_source = TRUE)
}
}

mydocument <- function() {
try(pkgload::unload("cgalMeshes"))
if(rstudioapi::isAvailable()) {
rstudioapi::restartSession(
"roxygen2::roxygenise(load_code = roxygen2::load_installed)"
)
} else {
roxygen2::roxygenise(load_code = roxygen2::load_installed)
}
source("C:/SL/MyPackages/cgalMeshes/inst/essais/clean-Rd3.R")
}
60 changes: 60 additions & 0 deletions inst/essais/essai-optimalBoundingBox.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
library(cgalMeshes)
library(rgl)
cyclide <- cyclideMesh(a = 97, c = 32, mu = 57)
cyclide <- HopfTorusMesh(nu = 50, nv = 50)
mesh <- cgalMesh$new(cyclide)
x <- mesh$optimalBoundingBox()
obb <- x[["rmesh"]]
obbMesh <- qmesh3d(
vertices = obb[["vertices"]],
indices = obb[["faces"]]
)

open3d(windowRect = 50 + c(0, 0, 512, 512), zoom = 0.9)
shade3d(cyclide, color = "green")
shade3d(obbMesh, color = "yellow", alpha = 0.3)

# tetrahedra ####
faces <- cbind(
c(1L, 2L, 3L),
c(3L, 2L, 4L),
c(4L, 2L, 1L),
c(1L, 3L, 4L)
)

pts <- x[["hxVertices"]]
vs1 <- pts[, c(1L, 5L, 3L, 7L)]
vs2 <- pts[, c(7L, 1L, 2L, 3L)]
vs3 <- pts[, c(6L, 1L, 7L, 5L)]
vs4 <- pts[, c(8L, 7L, 3L, 5L)]
vs5 <- pts[, c(4L, 1L, 3L, 5L)]

tth1 <- tmesh3d(
vertices = vs1,
indices = faces
)
tth2 <- tmesh3d(
vertices = vs2,
indices = faces
)
tth3 <- tmesh3d(
vertices = vs3,
indices = faces
)
tth4 <- tmesh3d(
vertices = vs4,
indices = faces
)
tth5 <- tmesh3d(
vertices = vs5,
indices = faces
)

open3d(windowRect = 50 + c(0, 0, 512, 512), zoom = 0.9)
shade3d(tth1, color = "red")
shade3d(tth2, color = "green")
shade3d(tth3, color = "blue")
shade3d(tth4, color = "yellow")
shade3d(tth5, color = "gray")
wire3d(obbMesh, color = "black")

0 comments on commit dc19502

Please sign in to comment.