23#ifndef VCL_ALGORITHMS_CORE_POLYGON_GEOMETRY_H
24#define VCL_ALGORITHMS_CORE_POLYGON_GEOMETRY_H
26#include <vclib/concepts/mesh/elements/face.h>
27#include <vclib/space/core/polygon.h>
28#include <vclib/views/mesh.h>
44template<FaceConcept FaceType>
45typename FaceType::VertexType::CoordType
faceNormal(
const FaceType& f)
47 using CoordType = FaceType::VertexType::CoordType;
50 f.vertex(0)->coord(), f.vertex(1)->coord(), f.vertex(2)->coord());
53 if (f.vertexNumber() == 3) {
57 f.vertex(2)->coord());
76template<FaceConcept FaceType>
79 using CoordType = FaceType::VertexType::CoordType;
82 f.vertex(0)->coord(), f.vertex(1)->coord(), f.vertex(2)->coord());
100template<FaceConcept FaceType>
103 using CoordType = FaceType::VertexType::CoordType;
106 f.vertex(0)->coord(), f.vertex(1)->coord(), f.vertex(2)->coord());
109 if (f.vertexNumber() == 3) {
111 f.vertex(0)->coord(),
112 f.vertex(1)->coord(),
113 f.vertex(2)->coord());
132template<FaceConcept FaceType>
135 using CoordType = FaceType::VertexType::CoordType;
138 f.vertex(0)->coord(), f.vertex(1)->coord(), f.vertex(2)->coord());
141 if (f.vertexNumber() == 3) {
143 f.vertex(0)->coord(),
144 f.vertex(1)->coord(),
145 f.vertex(2)->coord());
166template<FaceConcept FaceType>
169 const auto& p0 = f.vertex(
vi)->coord();
170 const auto& p1 = f.vertexMod((
int)
vi + 1)->coord();
171 const auto&
p2 = f.vertexMod((
int)
vi - 1)->coord();
172 return (
p2 - p0).angle(p1 - p0);
PointT normal() const
Computes the normal of the polygon.
Definition polygon.h:190
PointT barycenter() const
Computes the barycenter of the polygon.
Definition polygon.h:203
ScalarType area() const
Returns the area of the polygon.
Definition polygon.h:235
ScalarType perimeter() const
Returns the perimeter of the polygon.
Definition polygon.h:228
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
ScalarType area() const
Computes the area of the triangle.
Definition triangle.h:219
ScalarType perimeter() const
Computes the perimeter of the triangle.
Definition triangle.h:209
PointT barycenter() const
Computes the barycenter of the triangle.
Definition triangle.h:122
PointT normal() const
Returns the normal of the triangle.
Definition triangle.h:112
auto faceAngleOnVertexRad(const FaceType &f, uint vi)
Returns the internal angle (in radians) of the vi-th vertex of the face.
Definition geometry.h:167
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:133
FaceType::VertexType::CoordType faceNormal(const FaceType &f)
Computes the normal of a face, without modifying the face. Works both for triangle and polygonal face...
Definition geometry.h:45
FaceType::VertexType::CoordType 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:77
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:101