Skip to content

Commit a68540a

Browse files
dmurdochcran-robot
authored andcommitted
version 1.2.1
1 parent d926d87 commit a68540a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+18642
-2094
lines changed

DESCRIPTION

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: rgl
2-
Version: 1.1.3
2+
Version: 1.2.1
33
Title: 3D Visualization Using OpenGL
44
Authors@R: c(person("Duncan", "Murdoch", role = c("aut", "cre"),
55
email = "murdoch.duncan@gmail.com"),
@@ -31,7 +31,7 @@ Suggests: MASS, rmarkdown (>= 2.16), deldir (>= 1.0-4), orientlib,
3131
alphashape3d, tcltk, js (>= 1.2), webshot2 (>= 0.1.0), downlit
3232
(>= 0.4.0), pkgdown (>= 2.0.0), extrafont, shiny,
3333
manipulateWidget (>= 0.9.0), testthat, markdown, crosstalk, V8,
34-
chromote
34+
chromote, jpeg, png
3535
Imports: graphics, grDevices, stats, utils, htmlwidgets (>= 1.6.0),
3636
htmltools, knitr (>= 1.33), jsonlite (>= 0.9.20), magrittr, R6,
3737
base64enc, mime
@@ -53,7 +53,7 @@ VignetteBuilder: knitr, rmarkdown
5353
Biarch: true
5454
RoxygenNote: 7.2.2.9000
5555
NeedsCompilation: yes
56-
Packaged: 2023-03-13 21:32:28 UTC; murdoch
56+
Packaged: 2023-07-04 13:17:31 UTC; murdoch
5757
Author: Duncan Murdoch [aut, cre],
5858
Daniel Adler [aut],
5959
Oleg Nenadic [ctb],
@@ -78,4 +78,4 @@ Author: Duncan Murdoch [aut, cre],
7878
Mike Stein [ctb]
7979
Maintainer: Duncan Murdoch <murdoch.duncan@gmail.com>
8080
Repository: CRAN
81-
Date/Publication: 2023-03-26 22:30:02 UTC
81+
Date/Publication: 2023-07-06 00:10:42 UTC

MD5

+99-96
Large diffs are not rendered by default.

NAMESPACE

+3-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export(.check3d,
5353
spheres3d, spin3d, sprites3d, subdivision3d,
5454
subsceneInfo, subsceneList, Sweave.snapshot,
5555
surface3d, tagged3d, terrain3d,
56-
tetrahedron3d, text3d, texts3d,
56+
tetrahedron3d, text3d, texts3d, textureSource,
5757
thigmophobe3d, title3d,
5858
tkpar3dsave, tkspinControl, tkspin3d,
5959
toggleWidget, triangulate,
@@ -167,10 +167,11 @@ export(.check3d,
167167

168168
importFrom(graphics, legend, par, plot, plot.new, polygon,
169169
strwidth, strheight)
170-
importFrom(grDevices, col2rgb, colorRamp, dev.cur, dev.new,
170+
importFrom(grDevices, as.raster, col2rgb, colorRamp, dev.cur, dev.new,
171171
dev.off, png, postscript, rgb, xy.coords, xyz.coords)
172172
importFrom(stats, approxfun, get_all_vars, model.frame,
173173
qchisq, qf, splinefun, terms, var)
174+
importFrom(tools, file_ext)
174175
importFrom(utils, capture.output, count.fields, file_test,
175176
flush.console, packageVersion, read.table, head, tail)
176177
importFrom(R6, R6Class)

NEWS.md

+49
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,52 @@
1+
# rgl 1.2.1
2+
3+
## Major changes
4+
5+
* Support for non-PNG textures has been added. Currently
6+
supported: JPEG files and any other object
7+
for which `grDevices::as.raster()` works, e.g. matrices.
8+
(Fixes issue #196.)
9+
10+
## Minor changes
11+
12+
* Support for "alt" text has been added to `rglwidget()`.
13+
Full support in R Markdown or `knitr` requires a `knitr` update
14+
to version 1.42.12 or newer.
15+
* Some of the tests have been relaxed slightly so they
16+
shouldn't trigger errors on the M1Mac test platform.
17+
* Internally, the C++ code has dropped the use of the internally
18+
defined `String` type, settling on `std::string` instead.
19+
* `subdivision3d()`, `clipMesh3d()` and related functions now
20+
(optionally) record the original faces associated with each new one
21+
in a `mesh$tags` addition to the output.
22+
23+
## Bug fixes
24+
25+
* The `Makevars.win` file was being produced incorrectly on
26+
older Windows versions.
27+
* `rgl.window2user()` did not work correctly when multiple panes
28+
were showing. This caused `arrow3d()` to fail in some panes
29+
(issue #354).
30+
* `selectpoints3d()` had a typo which was revealed by
31+
warnings in recent R versions.
32+
* `getShaders()` was broken in 1.1.3.
33+
* `arc3d()` can now handle "arcs" that are straight lines along
34+
a radius (issue #357).
35+
* Spheres did not show textures correctly (issue #360).
36+
* `hover3d()` failed to display default labels in R (issue #362).
37+
* `shade3d()` didn't handle meshes with a mix of triangles and
38+
quads properly when `meshColor == "faces"`.
39+
* `subdivision3d()` and related functions now handle colors
40+
properly.
41+
* `addNormals()` sometimes gave `NaN` values due to rounding
42+
error (issue #372).
43+
* `arc3d()` sometimes missed plotting the last segment of the arc (issue #369).
44+
* `R_NO_REMAP` has been defined and header includes have been
45+
rearranged to prevent conflict between R internals and C++17
46+
library. (Thanks to Prof. B. D. Ripley and G. Csardi for
47+
suggested fixes.)
48+
49+
150
# rgl 1.1.3
251

352
## Major changes

R/addNormals.mesh3d.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,5 @@ xprod <- function(v, w) c( v[2]*w[3] - v[3]*w[2],
6262

6363
angle <- function(a,b) {
6464
dot <- sum(a*b)
65-
acos(dot/veclen(a)/veclen(b))
65+
acos(pmin(1, pmax(-1, dot/veclen(a)/veclen(b))))
6666
}

R/arc3d.R

+65-57
Original file line numberDiff line numberDiff line change
@@ -13,70 +13,78 @@ arc3d <- function(from, to, center, radius, n, circle = 50, base = 0, plot = TRU
1313
from <- fixarg(from)
1414
to <- fixarg(to)
1515
center <- fixarg(center)
16-
16+
1717
m <- max(nrow(from), nrow(to), nrow(center), length(base))
1818
base <- rep_len(base, m)
1919

2020
result <- matrix(NA_real_, nrow = 1, ncol = 3)
2121

2222
for (j in seq_len(m)) {
23-
from1 <- getrow(from, j)
24-
to1 <- getrow(to, j)
25-
center1 <- getrow(center, j)
26-
base1 <- base[j]
27-
logr1 <- log(veclen(from1 - center1))
28-
logr2 <- log(veclen(to1 - center1))
29-
A <- normalize(from1 - center1)
30-
B <- normalize(to1 - center1)
31-
steps <- if (base1 <= 0) 4*abs(base1) + 1 else 4*base1 - 1
32-
for (k in seq_len(steps)) {
33-
if (k %% 2) {
34-
A1 <- A * (-1)^(k %/% 2)
35-
B1 <- B * (-1)^(k %/% 2 + (base1 > 0))
36-
} else {
37-
A1 <- B * (-1)^(k %/% 2 + (base1 <= 0))
38-
B1 <- A * (-1)^(k %/% 2)
39-
}
40-
theta <- acos(sum(A1*B1))
41-
if (isTRUE(all.equal(theta, pi)))
42-
warning("Arc ", j, " points are opposite each other! Arc is not well defined.")
43-
if (missing(n))
44-
n1 <- ceiling(circle*theta/(2*pi))
45-
else
46-
n1 <- n
47-
48-
if (missing(radius)) {
49-
pretheta <- (k %/% 2)*pi - (k %% 2 == 0)*theta
50-
if (k == 1)
51-
totaltheta <- (steps %/% 2)*pi - (steps %% 2 == 0)*theta + theta
52-
p1 <- pretheta/totaltheta
53-
p2 <- (pretheta + theta)/totaltheta
54-
radius1 <- exp(seq(from = (1 - p1)*logr1 + p1*logr2,
55-
to = (1 - p2)*logr1 + p2*logr2,
56-
length.out = n1 + 1))
57-
} else
58-
radius1 <- rep_len(radius, n1)
59-
arc <- matrix(NA_real_, nrow = n1 + 1, ncol = 3)
60-
p <- seq(0, 1, length.out = n1 + 1)
61-
arc[1,] <- center1 + radius1[1]*A1
62-
arc[n1 + 1,] <- center1 + radius1[n1 + 1]*B1
63-
AB <- veclen(A1 - B1)
64-
for (i in seq_len(n1)[-1]) {
65-
ptheta <- p[i]*theta
66-
phi <- pi/2 + (0.5 - p[i])*theta
67-
q <- (sin(ptheta) / sin(phi))/AB
68-
D <- (1-q)*A1 + q*B1
69-
arc[i,] <- center1 + radius1[i] * normalize(D)
70-
}
71-
if (k == 1)
72-
result <- rbind(result, arc)
73-
else
74-
result <- rbind(result[-nrow(result), ,drop = FALSE], arc)
75-
}
76-
result <- rbind(result, result[1,])
23+
from1 <- getrow(from, j)
24+
to1 <- getrow(to, j)
25+
center1 <- getrow(center, j)
26+
# The "arc" might be a straight line
27+
if (isTRUE(all.equal(from1, center1)) ||
28+
isTRUE(all.equal(to1, center1)) ||
29+
isTRUE(all.equal(normalize(from1 - center1),
30+
normalize(to1 - center1)))) {
31+
result <- rbind(result, from1, to1)
32+
} else {
33+
base1 <- base[j]
34+
logr1 <- log(veclen(from1 - center1))
35+
logr2 <- log(veclen(to1 - center1))
36+
A <- normalize(from1 - center1)
37+
B <- normalize(to1 - center1)
38+
steps <- if (base1 <= 0) 4*abs(base1) + 1 else 4*base1 - 1
39+
for (k in seq_len(steps)) {
40+
if (k %% 2) {
41+
A1 <- A * (-1)^(k %/% 2)
42+
B1 <- B * (-1)^(k %/% 2 + (base1 > 0))
43+
} else {
44+
A1 <- B * (-1)^(k %/% 2 + (base1 <= 0))
45+
B1 <- A * (-1)^(k %/% 2)
46+
}
47+
theta <- acos(sum(A1*B1))
48+
if (isTRUE(all.equal(theta, pi)))
49+
warning("Arc ", j, " points are opposite each other! Arc is not well defined.")
50+
if (missing(n))
51+
n1 <- ceiling(circle*theta/(2*pi))
52+
else
53+
n1 <- n
54+
55+
if (missing(radius)) {
56+
pretheta <- (k %/% 2)*pi - (k %% 2 == 0)*theta
57+
if (k == 1)
58+
totaltheta <- (steps %/% 2)*pi - (steps %% 2 == 0)*theta + theta
59+
p1 <- pretheta/totaltheta
60+
p2 <- (pretheta + theta)/totaltheta
61+
radius1 <- exp(seq(from = (1 - p1)*logr1 + p1*logr2,
62+
to = (1 - p2)*logr1 + p2*logr2,
63+
length.out = n1 + 1))
64+
} else
65+
radius1 <- rep_len(radius, n1 + 1)
66+
arc <- matrix(NA_real_, nrow = n1 + 1, ncol = 3)
67+
p <- seq(0, 1, length.out = n1 + 1)
68+
arc[1,] <- center1 + radius1[1]*A1
69+
arc[n1 + 1,] <- center1 + radius1[n1 + 1]*B1
70+
AB <- veclen(A1 - B1)
71+
for (i in seq_len(n1)[-1]) {
72+
ptheta <- p[i]*theta
73+
phi <- pi/2 + (0.5 - p[i])*theta
74+
q <- (sin(ptheta) / sin(phi))/AB
75+
D <- (1-q)*A1 + q*B1
76+
arc[i,] <- center1 + radius1[i] * normalize(D)
77+
}
78+
if (k == 1)
79+
result <- rbind(result, arc)
80+
else
81+
result <- rbind(result[-nrow(result), ,drop = FALSE], arc)
82+
}
83+
}
84+
result <- rbind(result, result[1,])
7785
}
7886
if (plot)
79-
lines3d(result[c(-1, -nrow(result)), , drop = FALSE], ...)
87+
lines3d(result[c(-1, -nrow(result)), , drop = FALSE], ...)
8088
else
81-
result[c(-1, -nrow(result)), , drop = FALSE]
89+
result[c(-1, -nrow(result)), , drop = FALSE]
8290
}

0 commit comments

Comments
 (0)