# Interpolation of the values of points on the surface created by convex hull

5 views (last 30 days)

Show older comments

I have some 3D points like and their values like . The convex hull of these points are generated by convhull or convexHull (see figure below)

Now I want to interpolate the values of triangle vertices for N new points on the convex hull. What are the possible methods to do this?

##### 7 Comments

Matt J
on 5 Jul 2022

Edited: Matt J
on 5 Jul 2022

### Accepted Answer

### More Answers (2)

David Goodmanson
on 30 Jun 2022

Edited: David Goodmanson
on 30 Jun 2022

Hi Jose/Nima,

Suppose you have a triangle with vertex points p1, p2, p3, each of those defined by a column vector of their x,y,z coordinates. You can form the 3x3 matrix

M = [p1 p2 p3]

which is nonsingular if the vertex points are not colinear, which they are not in this case. Any point p0 (also defined by a column vector) is a linear combination of p1,p2,p3 with coefficients c = [c1;c2;c3]. In matrix notation that is M*c = p0

with solution

c = M\p0

For a quantity A with values A1,A2,A3 at points p1,p2,p3 respectively, the obvious way to interpolate and find the value at p0 is to use c1A1 + c2A2 + c3A3, or in matrix notation

Ainterp = c'*[A1;A2;A3]

so the three highlighted lines provide a solution. This is true whether p0 lies in the plane of the triangle or not, although it might not be a useful solution if p0 is far away from the triangle. If the point lies inside the triangle on the surface, I believe that 0<=c1<=1, 0<=c2<=1, 0<=c3<=1, c1+c2+c3 = 1 which is appropriate for intepolation.

##### 2 Comments

Torsten
on 30 Jun 2022

The interpolation suggested assumes that the function can be linearly approximated over the triangle:

f(p0) = f(c1*p1+c2*p2+c3*p3) =(*) c1*f(p1) + c2*f(p2) + c3*f(p3) = c1*A1 + c2*A2 + c3*A3

where at the =(*), the linearity of the function f is used.

This might or might not be a good choice.

Matt J
on 30 Jun 2022

Edited: Matt J
on 30 Jun 2022

For example, was the question targeted at sampling new points on the surface...?

Assuming that's the correct interpretation, then,

N=10;

P=rand(10,3);

k=convhull(P);

V=P(unique(k),:); %Generate vertices V

k=num2cell(convhull(V),1);

res=@(z) reshape(z,[],1,3); %Generate affine frame for each triangle

V0=res( V(k{1},:));

dV1=res( V(k{2},:)) -V0 ;

dV2=res( V(k{3},:)) -V0;

[a,b]=ndgrid(linspace(0,1,10)); %Sweep each triangle with extra samples

idx=a+b<=1;

a=a(idx)'; b=b(idx)';

XYZ=num2cell( reshape(V0+dV1.*a+dV2.*b ,[],3) ,1);

trisurf(cell2mat(k),V(:,1), V(:,2),V(:,3)); hold on %Visualize

scatter3(XYZ{:},'filled','r'); hold off

##### 0 Comments

### See Also

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!