compute_hausdorff_distance() method for bundle objects
Source: R/shape.R
compute_hausdorff_distance-fiber-bundle-method.RdDispatches to one of three behaviours depending on y:
Arguments
- x
A bundle object.
- y
NULL, a streamline, or a bundle.
Value
A
distobject of sizex@n_streamlineswhenyisNULLor a bundle. The lower triangle stores all pairwise symmetric Hausdorff distances (computed in C++). Useas.matrix()to obtain the full \(n \times n\) matrix.A numeric vector of length
x@n_streamlineswhenyis a streamline.
Details
y = NULL: pairwise distances withinxas adistobject of size \(n\), computed in C++ via a single linear loop.yis a streamline: numeric vector of distances fromyto each streamline inx.yis a bundle:distobject for the concatenation of all streamlines fromxandy.
Examples
pts1 <- matrix(runif(30), ncol = 3)
colnames(pts1) <- c("X", "Y", "Z")
pts2 <- matrix(runif(30), ncol = 3)
colnames(pts2) <- c("X", "Y", "Z")
sl1 <- streamline(points = pts1)
sl2 <- streamline(points = pts2)
b <- bundle(streamlines = list(sl1, sl2))
# pairwise dist object (size 2)
compute_hausdorff_distance(b)
#> 1
#> 2 0.5349375
as.matrix(compute_hausdorff_distance(b))
#> 1 2
#> 1 0.0000000 0.5349375
#> 2 0.5349375 0.0000000
# distances from sl1 to each streamline in b
compute_hausdorff_distance(b, sl1)
#> [1] 0.0000000 0.5349375