Learn R Programming

alphashape3d (version 1.3.2)

inashape3d: Test of the inside of an \(\alpha\)-shape

Description

This function checks whether points are inside an \(\alpha\)-shape.

Usage

inashape3d(as3d, indexAlpha = 1, points)

Value

If indexAlpha is a single value then the function returns a vector of boolean of length the number of input points. The element at position i is TRUE if the point in points[i,] is inside the \(\alpha\)-shape.

Otherwise inashape3d returns a list of vectors of boolean values (each object in the list as described above).

Arguments

as3d

An object of class "ashape3d" that represents the \(\alpha\)-shape of a given sample of points in the three-dimensional space, see ashape3d.

indexAlpha

A single value or vector with the indexes of as3d$alpha that should be used for the computation, see Details.

points

A 3-column matrix with the coordinates of the input points.

Details

The function inashape3d checks whether each point in points is inside the \(\alpha\)-shape for each value of \(\alpha\) in as3d$alpha[indexAlpha].

If indexAlpha="all" or indexAlpha="ALL" then the function checks whether each point in points is inside the \(\alpha\)-shape for all values of \(\alpha\) in as3d$alpha.

See Also

ashape3d

Examples

Run this code

T1 <- rtorus(2000, 0.5, 2)
T2 <- rtorus(2000, 0.5, 2, ct = c(2, 0, 0), rotx = pi/2)
x <- rbind(T1, T2)
ashape3d.obj <- ashape3d(x, alpha = 0.4)
# Random sample of points in a plane
points <- matrix(c(5*runif(10000) - 2.5, rep(0.01, 5000)), nc = 3)
in3d <- inashape3d(ashape3d.obj, points = points)
plot(ashape3d.obj, transparency = 0.2)
colors <- ifelse(in3d, "blue", "green")
points3d(points, col = colors)

Run the code above in your browser using DataLab