compute_hausdorff_distance() is an S7 generic that computes the symmetric
Hausdorff distance between streamline objects based on their 3-D
coordinate matrices, with methods available for the following classes:
The four dispatch cases are:
streamline+streamline: returns a single numeric scalar — the symmetric Hausdorff distance between the two streamlines.bundle+ missing: returns a symmetric numeric distance matrix of dimension \(n \times n\), where \(n\) is the number of streamlines in the bundle, giving all pairwise Hausdorff distances.bundle+streamline: returns a numeric vector of length \(n\) giving the Hausdorff distance fromyto each streamline inx.bundle+bundle: returns a symmetric numeric distance matrix of dimension \((n_x + n_y) \times (n_x + n_y)\), treating the concatenation of all streamlines fromxandyas one collection.
Arguments
- x
A streamline or bundle object.
- y
A streamline or bundle object, or
NULL(default). WhenNULLandxis a bundle, the pairwise distance matrix withinxis returned.
Value
A non-negative numeric scalar when both
xandyare streamlines.A
distobject of size \(n\) whenxis a bundle andyisNULLor a bundle (useas.matrix()to expand to a full \(n \times n\) matrix).A numeric vector of length \(n\) when
xis a bundle andyis a streamline.
Examples
pts1 <- matrix(runif(30), ncol = 3)
colnames(pts1) <- c("X", "Y", "Z")
sl1 <- streamline(points = pts1)
pts2 <- matrix(runif(30), ncol = 3)
colnames(pts2) <- c("X", "Y", "Z")
sl2 <- streamline(points = pts2)
# streamline x streamline -> scalar
compute_hausdorff_distance(sl1, sl2)
#> [1] 0.652874
# bundle x missing -> pairwise dist object
b <- bundle(streamlines = list(sl1, sl2))
compute_hausdorff_distance(b)
#> 1
#> 2 0.652874
as.matrix(compute_hausdorff_distance(b))
#> 1 2
#> 1 0.000000 0.652874
#> 2 0.652874 0.000000
# bundle x streamline -> vector
compute_hausdorff_distance(b, sl1)
#> [1] 0.000000 0.652874
# bundle x bundle -> combined pairwise matrix
b2 <- bundle(streamlines = list(sl2))
compute_hausdorff_distance(b, b2)
#> 1 2
#> 2 0.652874
#> 3 0.652874 0.000000