Learn R Programming

VoxR (version 0.5.1)

point.distance: Computing distance of points from a unique point

Description

Computing distance of points from a unique point within a point cloud.

Usage

point.distance(data, point)

Arguments

data
a data frame containing the x, y, z, ... coordinates of a point cloud
point
a vector containing the x, y, z coordinates of the reference point

Value

A vector containing the distance values of the points

See Also

axis.angle and axis.distance

Examples

Run this code
data(treecloud_vox)

#- computing distances

dist <- point.distance(treecloud_vox,point=c(0,0,0))
treecloud_vox[,4] <- dist

#-density plot

plot(density(dist,na.rm=TRUE))

#-3d visualisation

z <- c(sort(unique(round(treecloud_vox[,4],digits=2)),decreasing=TRUE))
col <- rainbow(n=length(z),start=0,end=2/6)
require(rgl)
library(rgl)
open3d()
for(i in 1:length(z)){
  	a <- subset(treecloud_vox,round(treecloud_vox[,4],digits=2)==z[i])
  	plot3d(a,col=col[i],add=TRUE)
 }

Run the code above in your browser using DataLab