Skip to contents

Mirrors the C# Bilinear interpolater of the Numerics library.

Usage

interpolate_2d(
  x1,
  x2,
  y,
  x1out,
  x2out,
  x1_transform = c("none", "logarithmic", "log", "normal_z"),
  x2_transform = c("none", "logarithmic", "log", "normal_z"),
  y_transform = c("none", "logarithmic", "log", "normal_z"),
  sort_order = c("ascending", "descending")
)

Arguments

x1, x2

numeric vectors of grid coordinates.

y

numeric matrix with length(x1) rows and length(x2) columns, y[i, j] the value at (x1[i], x2[j]).

x1out, x2out

numeric vectors of equal length, positions to interpolate at.

x1_transform, x2_transform, y_transform

one of "none" (the default), "logarithmic" (also accepted as "log"), or "normal_z". See the note on interpolate().

sort_order

"ascending" (the default) or "descending", describing x1 and x2.

Value

a numeric vector the same length as x1out/x2out.

Examples

interpolate_2d(c(1, 2, 3), c(1, 2, 3), diag(3), c(1.5), c(1.5))
#> [1] 0.5