by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Geometric Queries
Introduced first in SolidGeometry 2.8, Creation date: 2016-01-10, Last change: 2025-09-14
[ASUM,A]=SGarea(SG)
SG: | Solid Geoemtry |
ASUM: | Area of the surfaces | |
A: | Area list for facet list |
Try:
SGarea(SGbox([30,20,10])
This function, SGarea, calculates the area of surfaces in a solid geometry object, specifically using the vertices and facet list of the object. The function is part of the SG-Library and was created by Tim Lueth.
The function begins by checking the number of output arguments requested by the caller using nargout.
nargout is 0, the function calls VLFLarea with the vertices list SG.VL and the facet list SG.FL. It then sets the view for visualization using view(-30,30).nargout is not 0, the function calls VLFLarea with the same parameters and assigns the results to ASUM and A.The function VLFLarea is assumed to calculate the area of each facet using Heron's formula, which is mentioned in the comments. Heron's formula is used to calculate the area of a triangle when the lengths of all three sides are known. The semi-perimeter s is calculated as 0.5 * (a + b + c), where a, b, and c are the lengths of the sides of the triangle. The area A is then calculated as sqrt(s * (s - a) * (s - b) * (s - c)).
The function is designed to be used with solid geometry objects that have a defined structure with vertices and facets, allowing for the calculation of surface areas for 3D models.
Algorithm explaination created using ChatGPT on 2025-08-18 22:07. (Please note: No guarantee for the correctness of this explanation)