2

I have a 3d mesh and 11 static points with predefined values for them. Points are represented as an array of positions in 3d space and values:

 x: 0.3 y: 0.4, z: 0.5, value: 100,
 x: 0.6 y: 0.9, z: 0.66, value: 20,
 x: 0.4 y: 0.22, z: 0.35, value: 50,
 x: 0.11 y: 0.34, z: 0.65, value: 0,
 x: 0.35 y: 0.65, z: 0.5, value: 0,
 x: 0.22 y: 0.67, z: 0.5, value: 0,
 x: 0.43 y: 0.22, z: 0.5, value: 0,
 x: 0.67 y: 0.31, z: 0.5, value: 16,
 x: 0.84 y: 0.34, z: 0.5, value: 13,
 x: 0.22 y: 0.43, z: 0.5, value: 0,
 x: 0.13 y: 0.24, z: 0.5, value: 11,

I want to color faces of my 3d mesh and to make that I need to add some value for each face, depending on how far are they from this points. I already know the position of each face, but how to find their values? Which interpolation method/approach shall I use? For example this face x: 0.34, y: 0.43, z: 0.18, value: ? Ideally, I'm looking for some js/three.js solution/library to perform it on the frontend or some other python library to process it on the backend?

enter image description here

I found a couple of methods, but they work only in 2 or support only interpolation between 2 points, but how to apply it for an array?

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
andybelous
  • 45
  • 5

1 Answers1

2

I would use voxel map porting this Interpolating elements of a color matrix on the basis of some given reference elements into 3D. so simply instead of rendering triangles you render filled voxelized tetrahedrons... This will create regular map of colors which can be used along with trilinear interpolation to obtain color at any position.

another option is to find closest 4 reference points to your position so that your points lies inside tetrahedron and interpolate the color using something like trilinear interpolation you just use barycentric coordinates on each face of triangle ...

In case you got UV mapping of yoru mesh you can project your reference points to it and use 2D algorithms from there.

Spektre
  • 49,595
  • 11
  • 110
  • 380