Description Usage Arguments Value Author(s) References Examples
View source: R/interp.barycentric.R
ND barycentric interpolation at points Xi for a function with values f measured at locations X
1 | InterpBarycentric(X, f, Xi)
|
X |
An n-by-d matrix. The rows of x represent n points in d-dimensional space. |
f |
A vector of values nrow(X) long to be interpolated. |
Xi |
An ni-by-d matrix. The rows of xi represent n points in d-dimensional space whose positions in the mesh are being sought. |
matrix
Andrew Dolman <andrew.dolman@awi.de>
Adapted from code here: https://dahtah.wordpress.com/2013/03/06/barycentric-interpolation-fast-interpolation-on-arbitrary-grids/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | n <- 100
df <- data.frame(x = runif(n, -1, 1), y = runif(n, -1, 1), z = runif(n, -1, 1))
df$v <- with(df, 2*x + 1*y^2 + 3*z)
df.reg <- with(df, expand.grid(x = seq(min(x), max(x), length.out = 5),
y = seq(min(y), max(y), length.out = 5),
z = seq(min(z), max(z), length.out = 5)
))
out <- InterpBarycentric(X = df[,c(1,2,3)],
f = df$v,
Xi = df.reg)
out <- as.data.frame(out)
out$v_true <- with(out, 2*x + 1*y^2 + 3*z)
plot(v~v_true, data = out)
abline(0, 1)
hist(out$v - out$v_true)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.