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
sl1 <- streamline(points = cbind(X = runif(10), Y = runif(10), Z = runif(10)))
sl2 <- streamline(points = cbind(X = runif(10), Y = runif(10), Z = runif(10)))
# streamline x streamline -> scalar
compute_hausdorff_distance(sl1, sl2)
#> [1] 0.566281
# bundle x missing -> pairwise dist object
b <- bundle(streamlines = list(sl1, sl2))
compute_hausdorff_distance(b)
#> 1
#> 2 0.566281
as.matrix(compute_hausdorff_distance(b))
#> 1 2
#> 1 0.000000 0.566281
#> 2 0.566281 0.000000
# bundle x streamline -> vector
compute_hausdorff_distance(b, sl1)
#> [1] 0.000000 0.566281
# bundle x bundle -> combined pairwise matrix
b2 <- bundle(streamlines = list(sl2))
compute_hausdorff_distance(b, b2)
#> 1 2
#> 2 0.566281
#> 3 0.566281 0.000000
