制作时间序列的 3D 渲染图
我有一组 3D 坐标(下面 - 仅针对 3D 空间中的单个点):
x <- c(-521.531433, -521.511658, -521.515259, -521.518127, -521.563416, -521.558044, -521.571228, -521.607178, -521.631165, -521.659973)
y <- c(154.499557, 154.479568, 154.438705, 154.398682, 154.580688, 154.365189, 154.3564, 154.559189, 154.341309, 154.344223)
z <- c(864.379272, 864.354675, 864.365479, 864.363831, 864.495667, 864.35498, 864.358582, 864.50415, 864.35553, 864.359863)
xyz <- data.frame(x,y,z)
我需要使用 3D 渲染绘制该点的时间序列图(以便我可以旋转图等)。该图将可视化上述点在时间上的轨迹(例如以实线的形式)。我使用了 'rgl' 包 和 plot3d 方法,但我无法绘制时间序列(下面,仅从时间序列的第一帧绘制一个点):
require(rgl)
plot3d(xyz[1,1],xyz[1,2],xyz[1,3],axes=F,xlab="",ylab="",zlab="")
我发现 这篇文章,但它并没有真正处理实时渲染的 3D 绘图。我将不胜感激任何建议。谢谢。
I have a set of 3D coordinates (below - just for a single point, in 3D space):
x <- c(-521.531433, -521.511658, -521.515259, -521.518127, -521.563416, -521.558044, -521.571228, -521.607178, -521.631165, -521.659973)
y <- c(154.499557, 154.479568, 154.438705, 154.398682, 154.580688, 154.365189, 154.3564, 154.559189, 154.341309, 154.344223)
z <- c(864.379272, 864.354675, 864.365479, 864.363831, 864.495667, 864.35498, 864.358582, 864.50415, 864.35553, 864.359863)
xyz <- data.frame(x,y,z)
I need to make a time-series plot of this point with a 3D rendering (so I can rotate the plot, etc.). The plot will visualize a trajectory of the point above in time (for example in the form of solid line). I used 'rgl' package with plot3d method, but I can't make it to plot time-series (below, just plot a single point from first frame in time-series):
require(rgl)
plot3d(xyz[1,1],xyz[1,2],xyz[1,3],axes=F,xlab="",ylab="",zlab="")
I found this post, but it doesn't really deal with a real-time rendered 3D plots. I would appreciate any suggestions. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您阅读
help(plot3d)
您可以了解如何绘制线条:这是您想要的吗?
If you read
help(plot3d)
you can see how to draw lines:Is that what you want?
这个怎么样?它使用 rgl.pop() 删除点和线并将它们绘制为轨迹 - 更改 sleep 参数来控制速度:
How about this? It uses
rgl.pop()
to remove a point and a line and draw them as a trail - change the sleep argument to control the speed:解决方案比我想象的要简单,问题是我没有在数据上使用
as.matrix
。当我只是尝试使用plot3d
绘制整个数据集时,我收到错误(list) object Cannot be coerced to type 'double'
(找到了此问题的解决方案 此处)。因此,如果您需要绘制坐标集的时间序列(在我的例子中是两个演员的运动捕捉数据),这是我的完整解决方案(仅适用于下面的数据集!):将上述数据读入表格:
将 XYZ 坐标提取到单独的矩阵中:
使用 'rgl' 包:
<前><代码>要求(rgl)
plot3d(x[1:nrow(x),],y[1:nrow(y),],z[1:nrow(z),],axes=F,xlab="",ylab="",zlab =“”)
您应该得到如下图所示的内容(但您可以旋转它等) - 希望您能认识到那里有为人们提供的联合中心。我仍然需要调整它以使其在视觉上更好 - 将第一帧作为点(以清楚地看到演员的关节),然后是可见的中断,然后其余帧作为线。
The solution was simpler than I thought and the problem was that I didn't use
as.matrix
on my data. I was getting error(list) object cannot be coerced to type 'double'
when I was simply trying to plot my entire dataset usingplot3d
(found a solution for this here). So, if you need to plot time-series of set of coordinates (in my case motion capture data of two actors) here is my complete solution (only works with the data set below!):read the above data into a table:
extract XYZ coordinates into a separate matrixes:
plot the coordinates on a nice, 3D rendered plot using 'rgl' package:
You should get something like on the image below (but you can rotate it etc.) - hope you can recognise there are joint centers for people there. I still need to tweak it to make it visually better - to have first frame as a points (to clearly see actor's joints), then a visible break, and then the rest of frames as a lines.