distanceToPoint | R Documentation |
Compute the distance between the starting point of a track and a reference point. Useful to detect directed movement towards a point (see examples).
distanceToPoint(x, p = c(0, 0, 0), from = 1)
x |
a single input track; a matrix whose first column is time and whose remaining columns are a spatial coordinate. |
p |
numeric vector of coordinates of the reference point p to compute distances to. |
from |
index, or vector of indices, of the first row of the track. If
|
A single distance.
angleToPoint
to compute the angle to the reference point, and
AngleAnalysis
for other methods to compute angles and distances.
## Plotting the angle versus the distance to a reference point can be informative to
## detect biased movement towards that point. We should be suspicious especially
## when small angles are more frequent at lower distances.
steps <- subtracks( Neutrophils, 1 )
bb <- boundingBox( Neutrophils )
angles <- sapply( steps, angleToPoint, p = bb["max",-1] )
distances <- sapply( steps, distanceToPoint, p = bb["max",-1] )
scatter.smooth( distances, angles )
abline( h = 90, col = "red" )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.