简体   繁体   中英

Play3d in RGL package

I am working on a project using the RGL package in R programming. I would love if someone could help me with the play3d function of the same.

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.

I researched but all the available resources are about rotation of the polygon for t-duration. 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.

I want to translate my polygon for 10 seconds with some given parameters specifying how much to translate at each second.

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).

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

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

This is done in the ?rgl.setMouseCallbacks example.

Edited to add x, y, z values to answer question below.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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