get_surface: Get Surface

View source: R/get_surface.R

get_surfaceR Documentation

Get Surface

Description

Get Two-Dimensional Control Net and Surface from n-dimensional Control Nets

Usage

get_surface(x, margin = 1:2, at, n = 100)

Arguments

x

a cpr_cn object

margin

an integer identifying the marginal of the control net to slice along. Only used when working x is a cpr_cn object.

at

point value for marginals not defined in the margin. Only used when x is a cpr_cn object. Expected input is a list of length length(attr(x, "bspline_list")). Entries for elements marginal are ignored. If omitted, the midpoint between the boundary knots for each marginal is used.

n

the length of sequence to use for interpolating the spline function.

Value

a list with two elements

cn

the control net

surface

a data.frame with three columns to define the surface

See Also

get_spline

Examples


## Extract the control net and surface from a cpr_cn object.
a_cn <- cn(log10(pdg) ~ btensor(list(day, age, ttm)
           , df = list(15, 3, 5)
           , bknots = list(c(-1, 1), c(45, 53), c(-9, -1))
           , order = list(3, 2, 3))
           , data = spdg)

cn_and_surface <- get_surface(a_cn, n = 50)
str(cn_and_surface, max.level = 2)

old_par <- par()
par(mfrow = c(1, 2))
with(cn_and_surface$cn,
     plot3D::persp3D(unique(Var1),
                     unique(Var2),
                     matrix(z,
                            nrow = length(unique(Var1)),
                            ncol = length(unique(Var2))),
                     main = "Control Net")
     )
with(cn_and_surface$surface,
     plot3D::persp3D(unique(Var1),
                     unique(Var2),
                     matrix(z,
                            nrow = length(unique(Var1)),
                            ncol = length(unique(Var2))),
                     main = "Surface")
     )

par(old_par)


dewittpe/cpr documentation built on Feb. 16, 2024, 1:11 p.m.