I have two questions: 1- I was wondering how I can provide a custom base function for vtkThinPlateSplineTransform. For example, instead of R in a 3d scenario, I want to have the geodesic distance implemented into the algorithm. 2- Upon providing the custom function, apparently I have to provide the function’s derivative as well. Why? And how? Does vtk have some auto derivative option that I’m not aware of? Or it accepts some external libraries like Sacado? I could not find any extra information regarding my question, and I appreciate any help or suggestions.

It would be possible to subclass vtkThinPlateSplineTransform and then override the SetBasis() method to provide additional basis functions (the code for the new basis functions would also go in the subclass).

The derivative of the basis function is needed for two features of VTK transforms:

it is required for applying the transformation to vector data (as compared to simply transforming point coordinates)

it is required for transform inversion (the inversion solver uses Newton’s method, which requires the derivative)

For common basis functions (Gaussians, thin-plate spline, etc) it’s very easy to analytically compute the first derivative. I wrote this code more than twenty years ago, and only really intended to support the thin-plate spline basis functions. There is no auto derivative option. And no support for other libraries.

I didn’t ready your question clearly enough the first time. You say “instead of R”, so your custom base function isn’t a radial basis function? Unfortunately, the vtkThinPlateSplineTranform code can’t be adapted to work with any basis function that isn’t a radial basis function. Nearly all the math in the code assumes RBFs.