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

<p>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.</p>

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

<hr>

<p>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. </p>

<p>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.</p>

CC BY-SA 3.0
2017-06-20T15:11:31.440Z
One can backace cull the data and only consider the edges that adjoin a backface culled member.
joojaa
CC BY-SA 3.0
2017-06-20T15:13:27.907Z
@joojaa that's an equivalent way of generating perimeter candidates.
ratchet freak
CC BY-SA 3.0
2017-06-20T15:15:28.177Z
@LiordinoNeto cross product
ratchet freak
CC BY-SA 3.0
2017-06-20T15:20:35.003Z
@ratchetfreak this? 
`meshNormal = (0,0,0)
foreach vertexNormal in meshNormals
    meshNormal = meshNormal x vertexNormal`
Liordino Neto
CC BY-SA 3.0
2017-06-20T15:28:22.260Z
Yes but you get the area with those edges too.
joojaa
CC BY-SA 3.0
2017-06-20T15:32:00.527Z
@joojaa sorry, but I think I didn't understand. Are you talking about the arbitrary plane's normal calculation with the cross product? What edges exactly?
Liordino Neto
CC BY-SA 3.0
2017-06-20T16:01:37.917Z
@LiordinoNeto I wasnt talking to you no handle means i am talking to ratchett. Anyway face normal is different from vertex normals. Face normal is formed out of 2 triangle edges. Note this is why i asked about you knowing how the 3D view rendering works since now we are in fact telling you how the viewport rendering works in a roudabout way as the operations needed are exactly the same.
joojaa
CC BY-SA 3.0
2017-06-20T14:53:09.700Z
2017-06-20T14:53:09.700Z
ratchet freak
<p>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 <strong>area</strong> and <strong>perimeter</strong> calculations.</p>

<p>First, the <strong>area</strong>: 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 <code>(3 * 7.8)</code>, 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?</p>

<p>Now, for the <strong>perimeter</strong>: 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.</p>

CC BY-SA 3.0
2017-06-20T14:40:53.557Z
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.
joojaa
CC BY-SA 3.0
2017-06-20T14:52:38.187Z
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.
Liordino Neto
CC BY-SA 3.0
2017-06-20T15:14:21.520Z
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.
joojaa
CC BY-SA 3.0
2017-06-21T02:25:00.510Z
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?
JarkkoL
CC BY-SA 3.0
2017-06-21T12:12:47.627Z
@JarkkoL thanks for the suggestion. Summing up the areas of all the triangles of the original 3D mesh surface gives me the **surface area**, which I'm already calculating correctly. I don't know exactly how this is called, but what I need is a way to compute the planar area filled by this same mesh to apply in an architectural context.
Liordino Neto
CC BY-SA 3.0
2017-06-21T12:59:22.987Z
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.
JarkkoL
CC BY-SA 3.0
2017-06-21T14:07:24.833Z
@JarkkoL yes, you got it right. I'm working now on the backface culling with dot-product. Thanks!
Liordino Neto
CC BY-SA 3.0
2017-06-21T17:50:19.067Z
Just did the backface culling and now it's giving me results near what I expect. I suspect that the difference may be because I'm not accounting yet to partial occlusion. Will check on it to see what can be done. Thanks for the insights, everyone!
Liordino Neto
<computational-geometry><mesh><projections><area>
Compute area (not surface area) and perimeter of a mesh
Liordino Neto
# Compute area (not surface area) and perimeter of a mesh

(Asked by: username_0 on 2017-06-20)

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.

**Tags:** computational-geometry, mesh, projections, area

> **Comments:**
> **username_1**: 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.  
> **username_0**: 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.  
> **username_1**: 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.  
> **username_2**: 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?  
> **username_0**: @username_2 thanks for the suggestion. Summing up the areas of all the triangles of the original 3D mesh surface gives me the **surface area**, which I'm already calculating correctly. I don't know exactly how this is called, but what I need is a way to compute the planar area filled by this same mesh to apply in an architectural context.  
> **username_2**: 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.  
> **username_0**: @username_2 yes, you got it right. I'm working now on the backface culling with dot-product. Thanks!  
> **username_0**: Just did the backface culling and now it's giving me results near what I expect. I suspect that the difference may be because I'm not accounting yet to partial occlusion. Will check on it to see what can be done. Thanks for the insights, everyone!  

---

## 1 answers

### Answer by username_3 on 2017-06-20. Score: 2 | Accepted answer

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.

> **Comments:**
> **username_1**: One can backace cull the data and only consider the edges that adjoin a backface culled member.  
> **username_3**: @username_1 that's an equivalent way of generating perimeter candidates.  
> **username_3**: @username_0 cross product  
> **username_0**: @username_3 this?  `meshNormal = (0,0,0) foreach vertexNormal in meshNormals     meshNormal = meshNormal x vertexNormal`  
> **username_1**: Yes but you get the area with those edges too.  
> **username_0**: @username_1 sorry, but I think I didn't understand. Are you talking about the arbitrary plane's normal calculation with the cross product? What edges exactly?  
> **username_1**: @username_0 I wasnt talking to you no handle means i am talking to ratchett. Anyway face normal is different from vertex normals. Face normal is formed out of 2 triangle edges. Note this is why i asked about you knowing how the 3D view rendering works since now we are in fact telling you how the viewport rendering works in a roudabout way as the operations needed are exactly the same.  

---

