Integrating Trisurf for 3D Mesh Comparison in Domain D

  • Context: MATLAB 
  • Thread starter Thread starter member 428835
  • Start date Start date
  • Tags Tags
    Integrating
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 2K views
member 428835
Hi PF!

I have a 3D mesh generated via the trisurf function, where they each have different node numbers, but are both defined over the same domain ##D##. See attachments for clear image.

If the surfaces are ##f1## and ##f2##, I'd like to compute ##\iint_D(f1-f2)^2## where ##D = [0,2]\times[0,2]## . Any idea how?
 

Attachments

Physics news on Phys.org
Here is an example on how to do a double numerical integration:
http://www.mathworks.com/help/matlab/ref/trapz.html#buakefe-1_1

The idea is that you express the integrand as a matrix of values, then call trapz the first time operating on the rows, then take that result and integrate a second time operating on the columns. It looks something like this:

Code:
dx = 0.1;
dy = 0.1;
x = 0:dx:2;
y = 0:dy:2;
[X,Y] = meshgrid(x,y);   % create mesh
f1 = X.^2 + Y.^2;        % first surface defined on the mesh of (x,y) points
f2 = X.^2 + Y.^2 + 1;    % second surface
f = (f1 - f2).^2;        % integrand
Q = trapz(x,f,2);        % integrate wrt X
I = trapz(y,Q)           % integrate the result wrt Y

In this simple example you have the same surface separated vertically by 1 unit, so since the domain is a 2x2 square, you expect the integral to reproduce the volume of a 2x2x1 cube, which acts as a nice sanity check for the code above:

Code:
I =

    4

If the data you have for the surfaces is coarse, you can interpolate to define the surface on a finer mesh, then integrate the new surface.
 
Last edited: