23#ifndef VCL_MESH_ELEM_ALGORITHMS_POLYGON_GEOMETRY_H
24#define VCL_MESH_ELEM_ALGORITHMS_POLYGON_GEOMETRY_H
26#include <vclib/mesh/elements.h>
27#include <vclib/mesh/views/components.h>
29#include <vclib/space/core.h>
45template<FaceConcept FaceType>
46typename FaceType::VertexType::PositionType
faceNormal(
const FaceType& f)
48 using PositionType = FaceType::VertexType::PositionType;
51 f.vertex(0)->position(),
52 f.vertex(1)->position(),
53 f.vertex(2)->position());
56 if (f.vertexNumber() == 3) {
58 f.vertex(0)->position(),
59 f.vertex(1)->position(),
60 f.vertex(2)->position());
64 f.vertices() | views::positions);
80template<FaceConcept FaceType>
83 using PositionType = FaceType::VertexType::PositionType;
86 f.vertex(0)->position(),
87 f.vertex(1)->position(),
88 f.vertex(2)->position());
92 f.vertices() | views::positions);
107template<FaceConcept FaceType>
110 using PositionType = FaceType::VertexType::PositionType;
113 f.vertex(0)->position(),
114 f.vertex(1)->position(),
115 f.vertex(2)->position());
118 if (f.vertexNumber() == 3) {
120 f.vertex(0)->position(),
121 f.vertex(1)->position(),
122 f.vertex(2)->position());
141template<FaceConcept FaceType>
144 using PositionType = FaceType::VertexType::PositionType;
147 f.vertex(0)->position(),
148 f.vertex(1)->position(),
149 f.vertex(2)->position());
152 if (f.vertexNumber() == 3) {
154 f.vertex(0)->position(),
155 f.vertex(1)->position(),
156 f.vertex(2)->position());
160 f.vertices() | views::positions);
178template<FaceConcept FaceType>
181 const auto& p0 = f.vertex(
vi)->position();
182 const auto& p1 = f.vertexMod((
int)
vi + 1)->position();
183 const auto&
p2 = f.vertexMod((
int)
vi - 1)->position();
184 return (
p2 - p0).angle(p1 - p0);
A class representing a box in N-dimensional space.
Definition box.h:46
PointT normal() const
Computes the normal of the polygon.
Definition polygon.h:187
PointT barycenter() const
Computes the barycenter of the polygon.
Definition polygon.h:200
ScalarType area() const
Returns the area of the polygon.
Definition polygon.h:232
ScalarType perimeter() const
Returns the perimeter of the polygon.
Definition polygon.h:225
ScalarType area() const
Computes the area of the triangle.
Definition triangle.h:217
ScalarType perimeter() const
Computes the perimeter of the triangle.
Definition triangle.h:207
PointT barycenter() const
Computes the barycenter of the triangle.
Definition triangle.h:120
PointT normal() const
Returns the normal of the triangle.
Definition triangle.h:110
auto faceAngleOnVertexRad(const FaceType &f, uint vi)
Returns the internal angle (in radians) of the vi-th vertex of the face.
Definition geometry.h:179
auto facePerimeter(const FaceType &f)
Computes the perimeter of a face. Works both for triangle and polygonal faces, and it is optimized in...
Definition geometry.h:142
FaceType::VertexType::PositionType faceNormal(const FaceType &f)
Computes the normal of a face, without modifying the face. Works both for triangle and polygonal face...
Definition geometry.h:46
auto faceArea(const FaceType &f)
Computes the area of a face. Works both for triangle and polygonal faces, and it is optimized in case...
Definition geometry.h:108
FaceType::VertexType::PositionType faceBarycenter(const FaceType &f)
Computes the barycenter of a face. Works both for triangle and polygonal faces, and it is optimized i...
Definition geometry.h:81