# Inverse Distance Weighted interpolation between N Vector3s in Godot

I have a number of Vector3s in Godot arranged in a grid, let's say they look like this (looking at them from above, with Godot Y-is-up):

z
|(0,6,2) (1,5,2) (2,3,2)

|(0,2,1) (1,A,1) (2,3,1)

|(0,2,0) (1,3,0) (2,4,0)
--------------------------x


I would like to interpolate the center Y-value marked as A based on the surrounding vectors. The thing is, the center value is not bound to the grid, so it can be closer to the lower left corner for example, so I want to weight the interpolated value based on the distance to each vector.

So, is there some clever trick in Godot using built in functions, or do I need to implement my own Inverse Distance Weighting-code?

I believe you'll have to implement your own code. Perhaps the Vector3 functions cubic_interpolate or linear_interpolate will help.