File: qhull-eg.R

package info (click to toggle)
r-cran-geometry 0.5.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,964 kB
  • sloc: ansic: 20,610; cpp: 328; xml: 203; sh: 13; makefile: 5
file content (62 lines) | stat: -rw-r--r-- 1,644 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
### R code from vignette source 'qhull-eg.Rnw'

###################################################
### code chunk number 1: qhull-eg.Rnw:27-31
###################################################
library(geometry)
ps <-matrix(rnorm(30), , 2)
ch <- convhulln(ps)
head(ch)


###################################################
### code chunk number 2: qhull-eg.Rnw:43-47
###################################################
ps <-matrix(rnorm(30), , 2)
ch <- convhulln(ps, options="FA")
print(ch$area)
print(ch$vol)


###################################################
### code chunk number 3: qhull-eg.Rnw:51-52
###################################################
plot(ch)


###################################################
### code chunk number 4: qhull-eg.Rnw:56-58
###################################################
ch <- convhulln(ps, options="n")
head(ch$normals)


###################################################
### code chunk number 5: qhull-eg.Rnw:70-75
###################################################
tp <- rbox(n=200, D=2, B=4)
in_ch <- inhulln(ch, tp)
plot(tp[!in_ch,], col="gray")
points(tp[in_ch,], col="red")
plot(ch, add=TRUE)


###################################################
### code chunk number 6: qhull-eg.Rnw:86-91
###################################################
ps <- rbox(n=10, D=2)
dt <- delaunayn(ps)
head(dt)
trimesh(dt, ps)
points(ps)


###################################################
### code chunk number 7: qhull-eg.Rnw:102-106
###################################################
dt2 <- delaunayn(ps, options="Fa")
print(dt2$areas)
dt2 <- delaunayn(ps, options="Fn")
print(dt2$neighbours)