getPosition.Rd
Gets the x, y, z coordinates of the voxel center. If the voxel parameter is missing, it returns the positions of all the voxels in the voxel space.
getPosition(vxsp, vx)
# S4 method for VoxelSpace,vector
getPosition(vxsp, vx)
# S4 method for VoxelSpace,matrix
getPosition(vxsp, vx)
# S4 method for VoxelSpace,data.table
getPosition(vxsp, vx)
# S4 method for VoxelSpace,missing
getPosition(vxsp, vx)
a VoxelSpace
object.
(i, j, k) voxel coordinates as a data.table::data.table
with i, j, k columns, a vector (i, j, k) or a matrix with i, j, k columns.
the x, y, z coordinates of the voxel center.
# load a voxel file
vxsp <- readVoxelSpace(system.file("extdata", "tls_sample.vox", package = "AMAPVox"))
# get position of voxel(i=0, j=0, k=0)
getPosition(vxsp, c(0, 0, 0))
#> x y z
#> <num> <num> <num>
#> 1: 4 1 -1.5
# get position of voxels 1 to 10 in the data.table
getPosition(vxsp, vxsp@data[1:10,])
#> x y z
#> <num> <num> <num>
#> 1: 4 1 -1.5
#> 2: 4 1 -1.0
#> 3: 4 1 -0.5
#> 4: 4 1 0.0
#> 5: 4 1 0.5
#> 6: 4 1 1.0
#> 7: 4 1 1.5
#> 8: 4 1 2.0
#> 9: 4 1 2.5
#> 10: 4 1 3.0
# get positions of every voxel
getPosition(vxsp)
#> x y z
#> <num> <num> <num>
#> 1: 4 1.0 -1.5
#> 2: 4 1.0 -1.0
#> 3: 4 1.0 -0.5
#> 4: 4 1.0 0.0
#> 5: 4 1.0 0.5
#> ---
#> 416: 7 3.5 1.0
#> 417: 7 3.5 1.5
#> 418: 7 3.5 2.0
#> 419: 7 3.5 2.5
#> 420: 7 3.5 3.0