Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Numerical Integration over 3D mesh

  1. Apr 27, 2013 #1
    Hi, I have a mesh whose surface is made up of tesselating triangles. I would like to perform an integral over this surface of the form

    [itex]\int f(\Omega) R(\Omega) d\Omega [/itex]

    Where f is an arbitrary function and R is the radius at that point.

    I have a method implemented but it is not working correctly. I was wondering if anyone was aware of a better way.

    Basically my method is

    For each triangular face:

    1. Calculate the value of fR at each vertex of the face
    2. Calculate the average of these three values to find the average value of fR across the face.
    3. Multiply this value by the solid angle covered by the face.
    4. Sum up this result for all of the faces in the mesh.

    Unfortunately it doesn't seem to be working as I would have liked. Are there recommended ways of doing this kind of integration?

    (This is x-posted in another forum for those who may happend to see both)

  2. jcsd
  3. Apr 27, 2013 #2


    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    I think you need to consult with Messrs. Green and Gauss on this point,and possibly Mr. Stokes as well. Their integral theorems for vector calculus can provide the requisite tools to evaluate your integral.

    It's not clear from your description what R(Omega) and the variable Omega represent.
  4. Apr 28, 2013 #3
    Omega is the solid angle and d(Omega) is solid angle differential element

    [itex]d\Omega = sin\theta d\theta d\phi[/itex]

    Although I'm not computing it based on that equation, I'm computing it from the solid angle covered by the triangular element in question using the formula:

    [itex]E = (A+B+C) - \pi[/itex]

    Where A,B,C are angles of the spherical triangle with the same vertices as the triangle element.


  5. Apr 28, 2013 #4


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    In your integral you wrote [itex] f(\Omega) R(\Omega)[/itex] which is weird because [itex]\Omega[/itex] isn't actually representing coordinates - is it supposed to be spherical coordinates? And you're projecting out to the mesh or something?

    I think a bit more specific description of your integral might help - it's possible that you've forgotten a change of variable Jacobian without realizing it by attempting to write your integral down in a clever way
  6. Apr 28, 2013 #5
    Hi thepopasmurf!

    Let N be the number of facets of your tess.

    You want to approximate
    [tex] \int f(\Omega) R(\Omega) d\Omega \approx \frac{1}{3} \sum\limits_{i=1}^{N}{A(S_i) \sum\limits_{j=1}^{3}{f(v_j[S_i])R(v_j[S_i]) }}[/tex]
    with [tex]A(S_i)[/tex] denoting the area covered by the i-th Facet and [tex]v_j[S_i][/tex] its j-th vertex?

    That ansatz looks accurate at a first glance, except I'm not sure
    you did this one accurately; you're aware that the area of the [tex]S_i[/tex] in general depends on the embedding of the surface into the ℝ³, don`t you?

    Generally - what is the symptom of the failure you diagnose?

    Regards, Solkar
  7. Apr 28, 2013 #6
    But not on a second glance, because

    it's not R but R² needed.

    Thus, there's also a numerical issue, because simply taking the arithmetic mean of the radii of the adjacent vertices can cause a bad estimation.
  8. Apr 28, 2013 #7

    The specific integral I am trying to do is the spherical harmonic integrals,

    [itex]a_{vm} = A \int Y_{vm}(\theta, \phi) R(\theta,\phi) sin \theta d\theta d\phi [/itex]

    where Y_vm are the spherical harmonic functions and A is a normalisation constant. I used Omega to represent both theta and phi but apparently that convention is not as common as I thought.


    See my reply to Office_Shredder above, I'm fairly sure it's just R. The symptom of the failure I'm having is that when I try to reconstruct shapes after getting the coefficients there are large errors.
  9. Apr 28, 2013 #8
    Then integrate analytically with f = 1 and R = const and reconsider.
  10. Apr 29, 2013 #9
    The purpose of the integral is not to find the area, but to find the harmonic coefficients of R.
  11. Apr 29, 2013 #10
    But for your numerical integration you need the correct area element.
  12. Apr 29, 2013 #11
    Last edited by a moderator: May 6, 2017
  13. Apr 29, 2013 #12
    That's on a unit sphere so R=R²=1.
  14. Apr 29, 2013 #13
    I think it's fine that it's on a unit sphere because the distance part is accounted for in the integrand. And I'm not sure why I would have to add an extra R just because the function is the radius rather than any other function.

    Anyway, I think we're getting distracted by this point. I'm ultimately trying to solve this integral as an integral over theta and phi where the values of theta and phi available to me are from a mesh.

    If you think I should be using R^2 instead of R could you provide more details as to how I would proceed with that change. One issue I have with this point is that the units change.
  15. Apr 30, 2013 #14
    It's not question of "thinking" things, but about knowing Lebesgue measure and the foundations of differential geometry.

    For your numerics It is advisable to discard the smooth approach for calculating area and simply calculate the area of each triangular facet of your mesh; recall what you learned about cross products for that purpose.
  16. Apr 30, 2013 #15
    So should I change my integrand from

    [itex]\int Y R d\Omega[/itex]


    [itex]\int \frac{Y}{R} dA [/itex]

    to keep the units correct?
  17. Apr 30, 2013 #16
    It's somewhat amazing that people looking for help don't even read the answers given, let alone trying them

    This is your thread's title
    This is your starting point
    and you tried to numerically integrate a function on that by means of generalized Riemann partitioning.

    So what by all means should be unclear when I tell you to calculate the area of the tris of your tesselation?
    It's a most natural requisite for your integration algorithm, isn't it?
  18. Apr 30, 2013 #17
    I'm sorry that this is frustrating for you, but I'm not yet convinced that the area of the triangles is exactly what I want. I'll try to explain my approach in more detail.

    I have a mesh of an object made up of triangular faces. I'm trying to get the spherical harmonics components of the mesh

    [itex] a_{mn} = \int Y R d\Omega[/itex]

    I'm approximating this as

    [itex]a_{mn} = \sum Y_{mn} R_{mn} \Delta\Omega[/itex]

    Where Delta Omega is a small part of the solid angle. I know that the area is related to this, but this specific integral doesn't seem to require knowing the area directly of the triangular face, it requires knowing how much solid angle it covers.

    You could be right, but calculating the area of each triangle isn't useful to me directly. One problem is that the integrand has to be altered to keep the units consistant. So are you also suggesting a change of the integrand when you suggest that I use the area of the triangles?
  19. May 1, 2013 #18
    And I'm not yet convinced that you have any clue to what you try to do.
    So first better you try to convince me that you're not wasting my time here.
    Last edited: May 1, 2013
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook