as.mesh3d: Convert an object to an rgl mesh3d

Description Usage Arguments Details Value See Also Examples

Description

as.mesh3d.ashape3d converts an alphashape3d::ashape3d object into a nat/rgl compatible mesh3d surface

Note that this provides a link to the Rvcg package

as.mesh3d.boundingbox converts a nat boundingbox object into an rgl compatible mesh3d object.

Usage

1
2
3
4
5
6
7
8
9
## S3 method for class 'ashape3d'
as.mesh3d(x, tri_to_keep = 2L, ...)

## S3 method for class 'hxsurf'
as.mesh3d(x, Regions = NULL, material = NULL,
  drop = TRUE, ...)

## S3 method for class 'boundingbox'
as.mesh3d(x, ...)

Arguments

x

Object to convert to mesh3d

tri_to_keep

Which alphashape triangles to keep (expert use only - see triang entry in Value section of ashape3d docs for details.)

...

Additional arguments for methods

Regions

Character vector or regions to select from hxsurf object

material

rgl materials such as color

drop

Whether to drop unused vertices (default TRUE)

Details

An alpha shape is a generalisation of a convex hull enclosing a set of points. Unlike a convex hull, the resultant surface can be partly concave allowing the surface to more closely follow the set of points.

In this implementation, the parameter alpha is a scale factor with units of length that defines a spatial domain. When alpha is larger the alpha shape approaches the convex hull; when alpha is smaller the alpha shape has a greater number of faces / vertices i.e. it follows the points more closely.

Value

a mesh3d object which can be plotted and manipulated using rgl and nat packages.

See Also

ashape3d, mesh3d

as.mesh3d, tmesh3d, as.hxsurf, read.hxsurf

Other hxsurf: as.hxsurf, materials, plot3d.hxsurf, read.hxsurf, subset.hxsurf, write.hxsurf

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
library(alphashape3d)
kcs20.a=ashape3d(xyzmatrix(kcs20), alpha = 10)
plot(kcs20.a)

# convert to mesh3d
kcs20.mesh=as.mesh3d(kcs20.a)

# check that all points are inside mesh
all(pointsinside(kcs20, kcs20.mesh))
# and show that we can also use the alphashape directly
all(pointsinside(kcs20, kcs20.a))

clear3d()
wire3d(kcs20.mesh)
plot3d(kcs20, col=type, lwd=2)

bb=boundingbox(kcs20)
mbb=as.mesh3d(bb)

plot3d(kcs20)
# simple plot
plot3d(bb)
shade3d(mbb, col='red', alpha=0.3)

jefferis/nat documentation built on Oct. 25, 2018, 6:29 p.m.