2D Quadrilateral Interpolation: Barycentric Coordinates
Interpolation on a general quadrilateral
When dealing with general quadrilaterals, the explicit expression of the shape functions is not easy to found. But we have the possibility of computing the value of such functions on a point p using the barycentric coordinates for quadrilaterals.
Similar to the triangular interpolation, now consider a point
, in a quadrilateral defined by four vertices
numbered counterclokwise as usual(see figure). One can define the barycentric coordinades of this point which are equivalent to the value of the 2D shape functions
defined for this quadrilateral
: satisfying
. This way, one can express any point using four coordinates (barycentric)
. In particular
. The barycentric coordinates satisfy
. Moreover all
unless the point is outside of the quadrilater. Thus, the coordinates of the point
.To compute the values of
we re-write the previous equation as
.where 
Therefore,
Now to compute these two parameters, we rename the terms in the previous equation as:
where 
Finally we apply Newton's method to obtain
. Compute Barycentric Coordinates on a general quadrilateral
Given a quadrilateral defined by vertices
, compute the barycentric coordinates of point
. Verify that
. % define the previous notation
% we use (x,y) instead of (lambda, mu) for easy code
% solution is supposed to have 0 <= x <=1 and 0 <= y <=1
x=0.5; y=0.5; %initial point
while(norm(dx) > tol && iter < 20 )
%apply Newton-Rapson method to solve f(x,y)=0
f = a + b*x + c*y + d*x*y;
% Newton: x_{n+1} = x_n - (Df^-1)*f
% or equivalently denoting dx = x_{n+1}-x_n
Df(:,1)=(b + d*y); %df/dx
Df(:,2)=(c + d*x); %df/dy
bb=-f'; %independent term
if (norm([x,y]) > 10), iter=20; end %non convergent: just to save time
alpha1=(1-mu)*(1-lambda);
alphas=[alpha1,alpha2,alpha3,alpha4]
alphas=[-1,-1,-1,-1]; %wrong values
end
1.8750e-01 3.1250e-01 3.1250e-01 1.8750e-01
q=alpha1*v1+alpha2*v2+alpha3*v3+alpha4*v4;
p-q %we must recover the same point
plotRectangle(v1,v2,v3,v4);
Exercise 1:
From the previous code implement the function baryCoordQuad (the Quadrilateral version of the baryCoord function).
function [alphas,isInside]=baryCoordQuad(vertices,point)
Exercise 2:
From the mesh file meshTwoHolesQuad.m, find the quadrilateral where the point p=[39,7] belongs to.
Sol:
i = 404
vertices =
(c)Numerical Factory 2020