简体   繁体   English

在RGL包中的Play3d

[英]Play3d in RGL package

I am working on a project using the RGL package in R programming. 我正在使用R编程中的RGL包进行项目。 I would love if someone could help me with the play3d function of the same. 我很乐意,如果有人可以帮助我使用相同的play3d功能。

Here is what I plan to do. 这是我打算做的。 I have a polygon3d(x,y,z) that plots a polygon on the output window and now I would want to translate it with some value at each iteration, say by 10 units for 5 rounds. 我有一个polygon3d(x,y,z),它在输出窗口上绘制一个多边形,现在我想在每次迭代时用一些值来翻译它,比如10个单位的5轮。

I researched but all the available resources are about rotation of the polygon for t-duration. 我研究过,但所有可用的资源都是关于多边形旋转t持续时间。 Example of such a case is: 这种情况的例子是:

M <- par3d("userMatrix")
play3d( 
  par3dinterp(userMatrix=list(M,rotate3d(M, angle=pi, x=1 ,y=0, z=0))), 
  duration=10
)

The above code rotates my polygon along x-axis for 10seconds and stops. 上面的代码沿x轴旋转我的多边形10秒并停止。

I want to translate my polygon for 10 seconds with some given parameters specifying how much to translate at each second. 我想将我的多边形翻译10秒,其中一些给定的参数指定每秒翻译多少。

My polygon is basically a plus sign(representing a quadcopter) and I want to show the motion as if it is elevating from the ground(xy axis) into the air(z-axis). 我的多边形基本上是一个加号(代表一个四轴飞行器),我想要将运动显示为从地面(xy轴)升高到空气(z轴)。

Any help will be deeply appreciated. 任何帮助将深表感谢。

Thanks all 谢谢大家

You need to use the transpose of a translation matrix to do this. 您需要使用转换矩阵的转置来执行此操作。 For example, to translate by (x, y, z), use 例如,要翻译(x,y,z),请使用

M <- par3d("userMatrix")
play3d( 
  par3dinterp(userMatrix=list(M, M %*% t(translationMatrix(x, y, z)))), 
  duration=10
)

This is done in the ?rgl.setMouseCallbacks example. 这是在?rgl.setMouseCallbacks示例中完成的。

Edited to add x, y, z values to answer question below. 编辑添加x,y,z值以回答下面的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM