I am a student and I was looking through your website (the particular page I will be referencing is linked below) and I wanted to ask how your software is able to measure the 3D mesh for an accurate surface area. What process does it go through and what calculations does it use?
-
$\begingroup$ This may not be the complete answer you are looking for, but much of how the calculation is accomplished is revealed through the python code (particularily the bmesh code) outlined in this answer - blender.stackexchange.com/a/151217/75504 $\endgroup$– Christopher BennettCommented Jul 28, 2021 at 1:36
-
2$\begingroup$ The area of a parallelogram spanned by 2 edges (vectors) is given by the length of their cross-product, signed according to the right-hand rule. ( A triangle is half a parallelogram). $\endgroup$– Robin Betts ♦Commented Jul 28, 2021 at 6:31
1 Answer
The actual code for calculating the surface area that Blender uses internally, as opposed to the code that other scripts use, can be found in blender/object.cpp on Github.
static float object_surface_area(UpdateObjectTransformState *state,
const Transform &tfm,
Geometry *geom)
is the function that does so. It can be found at line 370.
It is, in fact, similar to the Python code found in most Python scripts, and can be summed up as "It calculates the sum of the area of each triangle in the mesh
Triangle area is calculated using an in line function found in blender/utils/math.h at line 464. It is
len(cross(v3 - v2, v1 - v2)) * 0.5f;
which is the same as @Robin Betts comment, since the area of a triangle is 1/2 the area of a parallelogram