I'm currently researching how to compute geometric properties of architectural shapes based on their 3D meshes, and am stuck for some time on the area and perimeter calculations.

First, the area: assuming that I have the proportions set right, if, for example, I have a wall with 3 meters of height, 7.8 meters of width and 0.290 meters of thickness I'm interested in the result of height * width (3 * 7.8), which would give me 23.4 meters in this case. My idea is to obtain a 2D projection of this 3D mesh onto a plane parallel to it, calculate the surface area of each triangle and sum them up, what I believe would give me the mesh area independent of it's shape, assuming that it is planar. The problem is, how exactly can I obtain this triangulated projection? I believe that if the mesh is aligned to the world axis it would simply be a matter of ignoring one of them, but unfortunatelly this is an assumption that can't be made, as there will be meshes rotated in relation to one or more axis, and just ignoring an axis would distort the projection. Aditionaly, is there any method that would work even in the case of a non-planar mesh?

Now, for the perimeter: having the area problem solved, is there any robust algorithm that would give me the contours of this 2D triangulated projection, and that would work with both convex and concave meshes? I believe that with this it would be a matter of simply adding up all the edges of the contour.

  • $\begingroup$ So, reading this it seems to me you do not know how the standard 3D camera projections work. Simply you transform vectors by the transformation matrix of the projection. $\endgroup$ – joojaa Jun 20 '17 at 14:40
  • $\begingroup$ Thanks for the answer! But wouldn't this give me a view-dependent projection? I'm interested in knowing exactly how to define a plane on which the mesh should be projected. $\endgroup$ – Liordino Neto Jun 20 '17 at 14:52
  • $\begingroup$ A view is a transform just like anything else. Nothing states that it has to be the same view as your viewport. So i take it you do not know how the camera works. $\endgroup$ – joojaa Jun 20 '17 at 15:14
  • 1
    $\begingroup$ For the area, why don't you just add up areas of the triangles in the original 3D mesh? What you need the projection for? The way you describe it sounds like an overcomplicated solution to a fairly straightforward problem. Or is it because you don't know how to calculate the area of a triangle in 3D? $\endgroup$ – JarkkoL Jun 21 '17 at 2:25
  • 1
    $\begingroup$ Ok, so your question really is "how do you calculate the projected area of a 3D object on an arbitrary 2D plane"? If the 3D object is convex, then it's quite simple (ignore backfacing triangles and project triangles using dot-product), but it's much more difficult for concave objects because you have to account for (partial) occlusion to avoid "double counting" areas. $\endgroup$ – JarkkoL Jun 21 '17 at 12:59

There's a small problem with your method. When the mesh self shadows then part of the model will be counted twice.

You can get the projection of a mesh onto an arbitrary plane by finding the rotation from the normal of the plane to the Z axis and rotating the mesh with it. After that you discard the Z component.

However it's more straightfoward to simply draw the mesh with appropriate projection and counting how many pixels it takes up.

An edge can be part of the perimeter only when both the triangles that make it are projected onto the same side of the projected line.

You can use that to walk around the perimeter. Start with the negative x most point after the rotation and follow the lines. When another potential perimeter line crosses the current line you start following that one instead.

  • $\begingroup$ One can backace cull the data and only consider the edges that adjoin a backface culled member. $\endgroup$ – joojaa Jun 20 '17 at 15:11
  • $\begingroup$ @joojaa that's an equivalent way of generating perimeter candidates. $\endgroup$ – ratchet freak Jun 20 '17 at 15:13
  • $\begingroup$ Thanks! I'll try your suggestions out and accept the answer if that is the case. One question though: which method should I use to find the normal of this arbitrary plane? For example, if I have a wall, I need to use its larger face as the arbitrary plane, so how should I compute it's normal? $\endgroup$ – Liordino Neto Jun 20 '17 at 15:14
  • 1
    $\begingroup$ @LiordinoNeto cross product $\endgroup$ – ratchet freak Jun 20 '17 at 15:15
  • $\begingroup$ @ratchetfreak this? meshNormal = (0,0,0) foreach vertexNormal in meshNormals meshNormal = meshNormal x vertexNormal $\endgroup$ – Liordino Neto Jun 20 '17 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.