Skip to content

Instantly share code, notes, and snippets.

@raphlinus
Last active June 6, 2019 14:59
Show Gist options
  • Save raphlinus/42e474ecaaa007ea989ca3a5f5e8a262 to your computer and use it in GitHub Desktop.
Save raphlinus/42e474ecaaa007ea989ca3a5f5e8a262 to your computer and use it in GitHub Desktop.
test of spline foo

scatter

This crate contains an implementation of Radial Basis Function multidimensional interpolation. For an excellent introduction to the topic, see the SIGGRAPH 2014 course notes.

The input is a set of datapoints, each of which has coordinates in some multidimensional space, and a value, also provided as a vector. For example, for the colorfield images below, the coordinates are 2D, and the values are a 3-vector, one each for red, green, and blue. The result is a Scatter struct that can then be evaluated at any coordinate. The idea is that the values vary smoothly with the coordinates, but coincide with the input at each of the provided datapoints.

There are a number of approaches to multidimensional interpolation, but the focus of this crate is the family of radial basis functions. These include [Polyharmonic splines], of which the thin plate spline is an instance, a Gaussian radial basis function, and others (muti-quadric and inverse multi-quadric). The Gaussian and multi-quadric variants have a tunable size parameter.

In addition, there is an "order" parameter that controls low-order polynomial terms. An order of 0 means no additional terms, just pure basis functions. An order of 1 means a constant term, and and order of 2 means an affine term. With these additional terms, there is a "best-fit" constant or affine approximation of the input, and the basis functions are layered. (For a more precise description, see section 3.1 of the SIGGRAPH notes). Note that even higher order polynomials make sense, but are not implemented currently.

Gaussian order 0 Gaussian order 1 Gaussian order 2

Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment