GOAL: I got from someone the python code for an RBF solver. The solver stores 9 transformation matrix (each of which, once decomposed, have tx, ty and tz set at 0 and sx, sy and sz set to 1, so only rotation actually has values). For each transformation matrix is also associate a vector of 3 values called sample.
the solver is applied to a transformation matrix in order to interpolate between the 9 samples stored previously and output the current value for that configuration. In the case the trasformation matrix is equal to one of the 9 stored, then the output will be exactly the sample associated to that particular matrix.
MATHEMATICAL STEPS THE CODE IS CURRENTLY FOLLOWING:
I will use a numerical examples. First step is to Store the 9 4x4 matrices as 1 9x9 matrix T (last row and column of transformation matrix is ignored since it has all zeros and a 1 in the last position.).
The samples associated to each transformation is stored in a 3x9 matrix S:
Then it gets the distance matrix from T by calculating the sum of the squared distances between all the elements of row1-row2, then between row1-row3, ... row2-row1, ... etc and for each distance it applied an RbfKernel Interpolation(in the current example just a simple square root).
Just to make it more clear, to calculate the second element of the first row of D, it would do:

It then inverts the distance matrix just calculated:
and calculates the weights in this way:
Last step consists in taking the input transform matrix L(a 4x4 matrix trasnformed into a 1x9 row vector for the same reason as the previously stored matrices) and calculate the distance(K) between that row-vector and each row of T with the same technique as above.
and as very last step, it multiply each element of K for the corresponding row(C) of W and sum together the 3 columns to find the outpute (O) 3 values. Practically speaking:
In this case, L is equal to the first row of T( small differences due to floating approximation to 2 decimal digits) and the final output is equal to the first row of S. If L would have been equal to the i.e. 3rd row of T, then O would have been equal to the 3rd row of S etc.
If L does not match any of the previous values, then O would interpolate between the samples and have different values.
QUESTION:
This steps are definitely working and giving the expected results, although I don't completely understand the logic behind. Until the point it calculates the distance matrix it makes sense, after that I don't understand why the matrix needs to be inverted and why the weights are the product between the inverted distance matrix and the samples.
So my question is, Can someone try to explain what is the logical meaning behind each step? Thanks!









I think I figured it out on my own. First thing the matrix K is actually a 3x9 matrix with each row being the same:
then, in terms of algebraic manipulations, this is the logic behind it:
Basically the product between the distances and the the weights (which really are the unkowns variables) must be equal to the samples. our output is then equal to the weights multiplied the current distances on the 3 samples values.
If anyone has a better explanation, I am eager to hear it.