# Compute area (not surface area) and perimeter of a mesh

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.

• 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. Jun 20 '17 at 14:40
• 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. Jun 20 '17 at 14:52
• 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. Jun 20 '17 at 15:14
• 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? Jun 21 '17 at 2:25
• 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. 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.

• One can backace cull the data and only consider the edges that adjoin a backface culled member. Jun 20 '17 at 15:11
• @joojaa that's an equivalent way of generating perimeter candidates. Jun 20 '17 at 15:13
• 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? Jun 20 '17 at 15:14
• @LiordinoNeto cross product Jun 20 '17 at 15:15
• @ratchetfreak this? meshNormal = (0,0,0) foreach vertexNormal in meshNormals meshNormal = meshNormal x vertexNormal Jun 20 '17 at 15:20