Recently I stumbled over the rgl-Package in R, which can be used to create interactive 3d plots. Now I want to visualize a set of boxes in one 3d plot. A Box B has cartesian coordinates B_coord=[x,y,z], which correspond to the lower left back corner and dimensions B_dim=[x1,y1,z1].
Apparently it is easy to draw, scale and position some cubes with the following exemplary code:
open3d()
printBox <- function(x,y,z,x1,y1,z1) {
mycube <- scale3d(cube3d(),x1,y1,z1)
wire3d(translate3d(mycube,x,y,z))
}
printBox(0,0,0,1,1,1)
With this code the boxes are moved to x,y,z and scaled to x1,y1,z1. My question is how to write a similar function with the same input which positions the boxes by the coordinates of their lower left back corner and draws a box with the dimensions x1, y1, z1. I am not tied to the rgl package and R, but I like its interactive 3d view.
Thank you for your ideas!
I think your code already does that. So as to make it more clear, and explain what those
rgl
functions do, I unrolled your function and commented it and put it in a more illustrative example.