https://github.com/stefanjohnsen/calculate3dpolygonarea
Calculating the area of planar non-complex polygons in 3D space
https://github.com/stefanjohnsen/calculate3dpolygonarea
3d-graphics area polygon triangulation
Last synced: 24 days ago
JSON representation
Calculating the area of planar non-complex polygons in 3D space
- Host: GitHub
- URL: https://github.com/stefanjohnsen/calculate3dpolygonarea
- Owner: StefanJohnsen
- License: mit
- Created: 2024-03-19T19:40:34.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-20T16:53:06.000Z (about 2 years ago)
- Last Synced: 2025-03-21T23:17:57.221Z (about 1 year ago)
- Topics: 3d-graphics, area, polygon, triangulation
- Language: C++
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Calculate 3D polygon area
Calculate3DPolygonArea provides a header-only solution for efficiently computing the area of non-complex polygons in 3D space.
This solution is self-contained, requiring no external libraries except for the inclusion of ``.
*This repository expands the functionality of the [Triangulate3DPolygon](https://github.com/StefanJohnsen/Triangulate3DPolygon) repository by incorporating the ability to calculate polygon area*
### Supported polygons
The solution works for all kinds of 3D non-complex polygons, concave or convex, open or closed.
### OS Support
- Windows
- Linux
- macOS
## Solution
By utilizing the process of triangulation, the area of a polygon is computed by breaking it down into triangles and then summing the areas of these individual components.
## Usage
Copy `TriangulatePolygonEx.h` to your project and include the file.
```cpp
#include
#include "TriangulatePolygonEx.h"
int main()
{
std::vector polygon;
polygon.emplace_back(0.0f, 0.0f, 0.0f);
polygon.emplace_back(2.0f, 0.0f, 0.0f);
polygon.emplace_back(2.0f, 2.0f, 0.0f);
polygon.emplace_back(0.0f, 2.0f, 0.0f);
const auto area = calculatePolygonArea(polygon);
std::cout << "Area " << area << std::endl;
}
```
## License
This software is released under the MIT License terms.