File: indices.R

package info (click to toggle)
rgl 1.3.34-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,968 kB
  • sloc: cpp: 23,234; ansic: 7,462; javascript: 6,125; sh: 3,555; makefile: 2
file content (38 lines) | stat: -rw-r--r-- 928 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
library(rgl)
tet <- tetrahedron3d()

open3d()
segments3d(t(tet$vb[1:3,]), indices = c(1,2,1,3,1,4,2,3,2,4,3,4))

open3d()
text3d(t(tet$vb[1:3,]), text=1:4)
triangles3d(t(tet$vb[1:3,]), indices = c(1,2,3,1,4,2,1,3,4,2,4,3),
            col = "red")

# This displayed a triangle for the red quad (issue #154)

quad <- cbind(x = c(-1, 1, 1, -1),
              y = c( 0, 0, 0, 0),
              z = c(-1, -1, 1, 1))/2
open3d()
triangles3d(quad, alpha = 0.5, col = "red", indices=c(1,2,3,1,3,4))
id <- triangles3d(quad+1, col = "blue", indices=c(1,2,3,1,3,4))

# These signalled errors or warnings

tri <- as.triangles3d(id)
m <- as.mesh3d(id)

filename <- tempfile(fileext = ".ply")
writePLY(filename)
unlink(filename)

filename <- tempfile(fileext = ".obj")
writeOBJ(filename, separateObjects = FALSE)
readOBJ(filename)
unlink(filename)

filename <- tempfile(fileext = ".stl")
writeSTL(filename)
readSTL(filename)
unlink(filename)