rtini_extract: Extract A Triangle Mesh With Approximation Error Below...

Description Usage Arguments Value See Also Examples

View source: R/extract.R

Description

Given a surface approximation error matrix as computed with rtini_error(), extract a triangle mesh that approximates the original heightmap with error less than or equal to a specified tolerance.

Usage

1
rtini_extract(error, tol)

Arguments

error

a numeric matrix as produced by rtini_error()

tol

scalar positive numeric, the error tolerance

Value

a list of numeric matrices. Each column in a matrix corresponds to the "linearized" vertex coordinates of a triangle. See examples for how to convert to x-y coordinates. Each matrix corresponds to a different approximation layer.

See Also

rtini_error()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
err <- rtini_error(volcano)
mesh <- rtini_extract(err, tol=10)

## Convert linearized indices to x/y in [0,1]
tris <- rbind(do.call(cbind, mesh), NA)
plot.new()
polygon(
  x=((tris - 1) %/% nrow(err)) / (ncol(err) - 1),
  y=((tris - 1) %% nrow(err)) / (nrow(err) - 1),
  col='grey90'
)

## One benefit of the linearized indices is that you can
## index directly into the height and error matrices.  Here
## We use that to show the errors at every point that was not
## plotted versus volcano height.
plot(volcano[-unlist(mesh)], err[-unlist(mesh)])

brodieG/rtini documentation built on Jan. 22, 2020, 2:03 a.m.