5

This very simple plot is stucking when dragging, rotating, etc. It's not slow, but the extend is changing making it really difficult to follow the data. It's because of the axis labels which are repositioned during the interaction. But why is this also if I set axis = FALSE? It's still jumping around... Any ideas?

library(rgl)

# has glitches during rotation, etc.
xyz = rbind(
  c(696640.9, 211180.6, 1125.691),
  c(696640.9, 211180.5, 1125.696),
  c(696640.9, 211180.1, 1125.725),
  c(696641.1, 211179.8, 1125.813)
)
plot3d(xyz, type="p", size=10)

# runs smoothly
xyz = rbind(
  c(6, 2, 1),
  c(9, 5, 6),
  c(4, 1, 5),
  c(1, 8, 3)
)
plot3d(xyz, type="p", size=10)

How can I fix this 'bug'? Thanks alot.

Also, due to the jumping, the positioning of the data itself seem to be corrupted. For example, the green line is touching the red line datawise. But that's not consistant for all viewing angles. enter image description here

EDIT

The suggested answer using scale() is fixing the issue for plot3d() but is not solving the issue for me. I'm adding more data to the plot with points3d(), segments3d() and abcline3d() which are then not well placed. Even if I use scale() also on the data added by these functions.

agoldev
  • 2,078
  • 3
  • 23
  • 38
  • 2
    Not a fix really, but a possible workaround might be to scale your data: `plot3d(scale(xyz), type="p", size=10)`, you'd have to think about how to construct axes if you don't like what that produces. – Jota Oct 24 '16 at 15:28
  • It looks like a real bug: I can confirm it happens on linux, in case it is relevant (recent Ubuntu 64 bits) – Jealie Oct 24 '16 at 17:17
  • rgl uses single precision in various places. This was necessary when it was first written 15 years ago, but might not be nowadays. Single precision only gives about 6-7 digit accuracy, so you're seeing rounding error. Following Jota's suggestion is the best workaround. – user2554330 Oct 24 '16 at 21:01
  • hm, ok. Is there a library more up to date? In this case, I can't use scale() since I'm adding data later to the plot with abcline3d(). – agoldev Oct 25 '16 at 08:45
  • Scale (or just centre) your data before you start, and scale everything. `rgl` isn't the only thing that will suffer because your data is so badly scaled, it's just particularly sensitive to bad data storage. – user2554330 Oct 27 '16 at 20:34

0 Answers0