Loading [MathJax]/extensions/tex2jax.js
MeshKernel
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages Concepts
Operations.hpp
1//---- GPL ---------------------------------------------------------------------
2//
3// Copyright (C) Stichting Deltares, 2011-2021.
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation version 3.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16//
17// contact: delft3d.support@deltares.nl
18// Stichting Deltares
19// P.O. Box 177
20// 2600 MH Delft, The Netherlands
21//
22// All indications and logos of, and references to, "Delft3D" and "Deltares"
23// are registered trademarks of Stichting Deltares, and remain the property of
24// Stichting Deltares. All rights reserved.
25//
26//------------------------------------------------------------------------------
27
28#pragma once
29
30#include <iostream>
31#include <numeric>
32#include <span>
33#include <vector>
34
35#include "MeshKernel/BoundingBox.hpp"
36#include "MeshKernel/Constants.hpp"
37#include "MeshKernel/Entities.hpp"
38#include "MeshKernel/Utilities/LinearAlgebra.hpp"
39#include "MeshKernel/Utilities/RTreeBase.hpp"
40#include "MeshKernel/Vector.hpp"
41
42namespace meshkernel
43{
51 template <typename T>
52 void ResizeAndFill2DVector(std::vector<std::vector<T>>& v, UInt const& firstDimension, UInt const& secondDimension, bool fill = false, const T& fillValue = {})
53 {
54 v.resize(firstDimension);
55 for (auto& e : v)
56 {
57 e.resize(secondDimension);
58 if (fill)
59 {
60 std::fill(e.begin(), e.end(), fillValue);
61 }
62 }
63 }
64
73 template <typename T>
74 void ResizeAndFill3DVector(std::vector<std::vector<std::vector<T>>>& v, UInt const& firstDimension, UInt const& secondDimension, UInt const& thirdDim, bool fill = false, const T& fillValue = {})
75 {
76 v.resize(firstDimension);
77 for (auto& e : v)
78 {
79 e.resize(secondDimension);
80 for (auto& ee : e)
81 {
82 ee.resize(thirdDim);
83 if (fill)
84 {
85 std::fill(ee.begin(), ee.end(), fillValue);
86 }
87 }
88 }
89 }
90
95 template <typename T>
96 [[nodiscard]] UInt FindIndex(const std::vector<T>& vec, T el)
97 {
98 for (UInt n = 0; n < vec.size(); n++)
99 {
100 if (vec[n] == el)
101 {
102 return n;
103 }
104 }
105
106 return constants::missing::uintValue;
107 }
108
110 template <typename T>
111 UInt FindNextIndex(const std::vector<T>& vec, UInt current)
112 {
113 if (vec.size() == 0) [[unlikely]]
114 {
115 return constants::missing::uintValue;
116 }
117
118 return current == vec.size() - 1 ? 0 : current + 1;
119 }
120
122 template <typename T>
123 UInt FindPreviousIndex(const std::vector<T>& vec, UInt current)
124 {
125 if (vec.size() == 0) [[unlikely]]
126 {
127 return constants::missing::uintValue;
128 }
129
130 return current == 0 ? static_cast<UInt>(vec.size()) - 1 : current - 1;
131 }
132
139 std::vector<std::pair<UInt, UInt>> FindIndices(const std::vector<Point>& vec, size_t start, size_t end, double separator);
140
142 UInt InvalidPointCount(const std::vector<Point>& points);
143
148 UInt InvalidPointCount(const std::vector<Point>& points, size_t start, size_t end);
149
153 template <typename T>
154 [[nodiscard]] std::vector<UInt> SortedIndices(const std::vector<T>& v)
155 {
156 std::vector<UInt> indices(v.size());
157 iota(indices.begin(), indices.end(), 0);
158 std::ranges::stable_sort(indices.begin(), indices.end(), [&v](UInt i1, UInt i2)
159 { return v[i1] < v[i2]; });
160 return indices;
161 }
162
167 template <typename T>
168 auto ReorderVector(const std::vector<T>& v, const std::vector<UInt>& order)
169 {
170 std::vector<T> ordered;
171 ordered.reserve(v.size());
172 for (const auto& value : order)
173 {
174 ordered.emplace_back(v[value]);
175 }
176 return ordered;
177 }
178
184 template <typename F>
185 [[nodiscard]] double FindFunctionRootWithGoldenSectionSearch(F func, double min, double max)
186 {
187 // golden distance factors
188 const double c = 0.38196602;
189 const double r = 0.61803399;
190 const double tolerance = 1e-5;
191
192 double left = min;
193 double middle = (min + max) * 0.5;
194 double right = max;
195
196 double x0 = left;
197 double x1 = middle - c * (middle - left);
198 double x2 = middle;
199 double x3 = right;
200 if (std::abs(right - middle) > std::abs(middle - left))
201 {
202 x1 = middle;
203 x2 = middle + c * (right - left);
204 }
205
206 double f1 = func(x1);
207 double f2 = func(x2);
208
209 while (std::abs(x3 - x0) > tolerance * std::max(std::abs(x1) + std::abs(x2), 1e-8)) // tolerance * std::max(std::abs(x1) + std::abs(x2), 1e-10)
210 {
211 if (f2 < f1)
212 {
213 x0 = x1;
214 x1 = x2;
215 x2 = r * x1 + c * x3;
216
217 f1 = f2;
218 f2 = func(x2);
219 }
220 else
221 {
222 x3 = x2;
223 x2 = x1;
224 x1 = r * x2 + c * x0;
225
226 f2 = f1;
227 f1 = func(x1);
228 }
229 }
230
231 return f1 < f2 ? x1 : x2;
232 }
233
238 [[nodiscard]] UInt NextCircularForwardIndex(UInt currentIndex, UInt size);
239
244 [[nodiscard]] UInt NextCircularBackwardIndex(UInt currentIndex, UInt size);
245
249 [[nodiscard]] bool IsPointOnPole(const Point& point);
250
258 [[nodiscard]] double crossProduct(const Point& firstSegmentFirstPoint, const Point& firstSegmentSecondPoint, const Point& secondSegmentFirstPoint, const Point& secondSegmentSecondPoint, const Projection& projection);
259
268 [[nodiscard]] bool IsPointInPolygonNodes(const Point& point,
269 const std::vector<Point>& polygonNodes,
270 const Projection& projection,
271 Point polygonCenter = {constants::missing::doubleValue, constants::missing::doubleValue},
272 UInt startNode = constants::missing::uintValue,
273 UInt endNode = constants::missing::uintValue);
274
284 [[nodiscard]] bool IsPointInPolygonNodes(const Point& point,
285 const std::vector<Point>& polygonNodes,
286 const Projection& projection,
287 const BoundingBox& boundingBox,
288 Point polygonCenter = {constants::missing::doubleValue, constants::missing::doubleValue},
289 UInt startNode = constants::missing::uintValue,
290 UInt endNode = constants::missing::uintValue);
291
297 [[nodiscard]] bool IsPointInTriangle(const Point& point,
298 const std::span<const Point> triangleNodes,
299 const Projection& projection);
300
302 void ComputeThreeBaseComponents(const Point& point, std::array<double, 3>& exxp, std::array<double, 3>& eyyp, std::array<double, 3>& ezzp);
303
305 void ComputeTwoBaseComponents(const Point& point, double (&elambda)[3], double (&ephi)[3]);
306
311 [[nodiscard]] double GetDx(const Point& firstPoint, const Point& secondPoint, const Projection& projection);
312
317 Vector GetDelta(const Point& firstPoint, const Point& secondPoint, const Projection& projection);
318
325 Vector ComputeNormalToline(const Point& start, const Point& end, const Projection projection);
326
331 [[nodiscard]] double GetDy(const Point& firstPoint, const Point& secondPoint, const Projection& projection);
332
334 [[nodiscard]] double OuterProductTwoSegments(const Point& firstPointFirstSegment, const Point& secondPointFirstSegment,
335 const Point& firstPointSecondSegment, const Point& secondPointSecondSegment, const Projection& projection);
336
342 [[nodiscard]] Point ComputeMiddlePoint(const Point& firstPoint, const Point& secondPoint, const Projection& projection);
343
349 [[nodiscard]] Point ComputeMiddlePointAccountingForPoles(const Point& firstPoint, const Point& secondPoint, const Projection& projection);
350
357 [[nodiscard]] Point NormalVector(const Point& firstPoint, const Point& secondPoint, const Point& insidePoint, const Projection& projection);
358
361 void TransformGlobalVectorToLocal(const Point& reference, const Point& globalCoordinates, const Point& globalComponents, const Projection& projection, Point& localComponents);
362
367 Point NormalVectorOutside(const Point& firstPoint, const Point& secondPoint, const Projection& projection);
368
373 void NormalVectorInside(const Point& firstPoint, const Point& secondPoint, const Point& insidePoint, Point& normal, bool& flippedNormal, const Projection& projection);
374
381 void AddIncrementToPoint(const Point& normal, double increment, const Point& referencePoint, const Projection& projection, Point& point);
382
386 void TranslateSphericalCoordinates(std::vector<Point>& polygon);
387
392 [[nodiscard]] Point ReferencePoint(const std::vector<Point>& polygon, const Projection& projection);
393
399 [[nodiscard]] Point ReferencePoint(const std::vector<Point>& nodes,
400 const std::vector<UInt>& polygonIndices,
401 const Projection& projection);
402
409 [[nodiscard]] double ComputeSquaredDistance(const Point& firstPoint, const Point& secondPoint, const Projection& projection);
410
416 [[nodiscard]] double ComputeDistance(const Point& firstPoint, const Point& secondPoint, const Projection& projection);
417
424 [[maybe_unused]] std::tuple<double, Point, double> DistanceFromLine(const Point& point, const Point& firstNode, const Point& secondNode, const Projection& projection);
425
433 [[nodiscard]] double InnerProductTwoSegments(const Point& firstPointFirstSegment, const Point& secondPointFirstSegment, const Point& firstPointSecondSegment, const Point& secondPointSecondSegment, const Projection& projection);
434
442 [[nodiscard]] double NormalizedInnerProductTwoSegments(const Point& firstPointFirstSegment, const Point& secondPointFirstSegment, const Point& firstPointSecondSegment, const Point& secondPointSecondSegment, const Projection& projection);
443
450 [[nodiscard]] Point CircumcenterOfTriangle(const Point& firstNode, const Point& secondNode, const Point& thirdNode, const Projection& projection);
451
453 UInt CountNumberOfValidEdges(const std::vector<UInt>& edgesNumFaces, UInt numNodes);
454
456 void ComputeMidPointsAndNormals(const std::vector<Point>& polygon,
457 const std::vector<UInt>& edgesNumFaces,
458 const UInt numNodes,
459 std::array<Point, constants::geometric::maximumNumberOfNodesPerFace>& middlePoints,
460 std::array<Point, constants::geometric::maximumNumberOfNodesPerFace>& normals,
461 UInt& pointCount,
462 const Projection& projection);
463
465 Point ComputeCircumCenter(const Point& centerOfMass,
466 const UInt pointCount,
467 const std::array<Point, constants::geometric::maximumNumberOfNodesPerFace>& middlePoints,
468 const std::array<Point, constants::geometric::maximumNumberOfNodesPerFace>& normals,
469 const Projection& projection);
470
472 Point ComputeFaceCircumenter(std::vector<Point>& polygon,
473 const std::vector<UInt>& edgesNumFaces,
474 const Projection& projection);
475
489 [[nodiscard]] std::tuple<bool, Point, double, double, double> AreSegmentsCrossing(const Point& firstSegmentFirstPoint,
490 const Point& firstSegmentSecondPoint,
491 const Point& secondSegmentFirstPoint,
492 const Point& secondSegmentSecondPoint,
493 bool adimensionalCrossProduct,
494 const Projection& projection);
495
501 template <typename T>
502 [[nodiscard]] T ComputePointOnSplineAtAdimensionalDistance(const std::vector<T>& coordinates,
503 const std::vector<T>& coordinatesDerivatives,
504 double pointAdimensionalCoordinate)
505 {
506 T pointCoordinate{};
507 if (pointAdimensionalCoordinate < 0)
508 {
509 return pointCoordinate;
510 }
511
512 const double eps = 1e-5;
513 const double splFac = 1.0;
514 const auto coordinate = std::floor(pointAdimensionalCoordinate);
515
516 if (pointAdimensionalCoordinate - coordinate < eps)
517 {
518 return pointCoordinate = coordinates[static_cast<UInt>(coordinate)];
519 }
520
521 const UInt low = static_cast<UInt>(coordinate);
522 const UInt high = low + 1;
523 const double a = high - pointAdimensionalCoordinate;
524 const double b = pointAdimensionalCoordinate - low;
525
526 pointCoordinate = coordinates[low] * a + coordinates[high] * b +
527 (coordinatesDerivatives[low] * (pow(a, 3) - a) + coordinatesDerivatives[high] * (pow(b, 3) - b)) / 6.0 * splFac;
528
529 return pointCoordinate;
530 }
531
536 std::tuple<std::vector<double>, double> ComputeAdimensionalDistancesFromPointSerie(const std::vector<Point>& v, const Projection& projection);
537
542 template <typename T>
543 [[nodiscard]] int sgn(T val)
544 {
545 return (T(0) < val ? 1 : 0) - (val < T(0) ? 1 : 0);
546 }
547
557 [[nodiscard]] lin_alg::Matrix<Point> DiscretizeTransfinite(const std::vector<Point>& leftDiscretization,
558 const std::vector<Point>& rightDiscretization,
559 const std::vector<Point>& bottomDiscretization,
560 const std::vector<Point>& upperDiscretization,
561 const Projection& projection,
562 UInt numM,
563 UInt numN);
564
569 [[nodiscard]] std::vector<Point> ComputeEdgeCenters(const std::vector<Point>& nodes, const std::vector<Edge>& edges);
570
577 [[nodiscard]] double LinearInterpolationInTriangle(const Point& interpolationPoint, const std::vector<Point>& polygon, const std::vector<double>& values, const Projection& projection);
578
583 [[nodiscard]] Point ComputeAverageCoordinate(const std::span<const Point> points, const Projection& projection);
584
591 std::tuple<Point, double, bool> OrthogonalProjectionOnSegment(Point const& firstNode,
592 Point const& secondNode,
593 Point const& pointToProject);
594
599 UInt AbsoluteDifference(UInt number_1, UInt number_2);
600
606 [[nodiscard]] std::vector<Point> ComputePolyLineDiscretization(std::vector<Point> const& polyline, std::vector<double>& chainages, Projection projection);
607
612 [[nodiscard]] std::vector<double> ComputePolyLineNodalChainages(std::vector<Point> const& polyline, Projection projection);
613
618 [[nodiscard]] std::vector<double> ComputePolyLineEdgesLengths(std::vector<Point> const& polyline, Projection projection);
619
625 [[nodiscard]] double MatrixNorm(const std::vector<double>& x, const std::vector<double>& y, const std::vector<double>& matCoefficients);
626
628 inline void IncrementValidValue(UInt& value, const UInt increment)
629 {
630 if (value != constants::missing::uintValue) [[likely]]
631 {
632 value += increment;
633 }
634 }
635
636} // namespace meshkernel
A class defining a bounding box.
Definition BoundingBox.hpp:40
A struct describing a point in a two-dimensional space.
Definition Point.hpp:41
A class defining a vector.
Definition Vector.hpp:39
Contains the logic of the C++ static library.
Definition AveragingInterpolation.hpp:37
UInt NextCircularForwardIndex(UInt currentIndex, UInt size)
Get the next forward index, for a range in 0 .. size-1.
Point ComputeAverageCoordinate(const std::span< const Point > points, const Projection &projection)
Given a series of point computes the average coordinate.
void AddIncrementToPoint(const Point &normal, double increment, const Point &referencePoint, const Projection &projection, Point &point)
Moves a point by adding an increment vector to it.
double GetDy(const Point &firstPoint, const Point &secondPoint, const Projection &projection)
Gets dy for the given projection.
Projection
Enumerator describing the supported projections.
Definition Definitions.hpp:43
Point ComputeCircumCenter(const Point &centerOfMass, const UInt pointCount, const std::array< Point, constants::geometric::maximumNumberOfNodesPerFace > &middlePoints, const std::array< Point, constants::geometric::maximumNumberOfNodesPerFace > &normals, const Projection &projection)
Compute circumcenter of face.
UInt FindNextIndex(const std::vector< T > &vec, UInt current)
Find the next index in the vector, wraps around when current is the last index.
Definition Operations.hpp:111
Vector GetDelta(const Point &firstPoint, const Point &secondPoint, const Projection &projection)
Get the delta (dx, dy) for the given projection.
Point ReferencePoint(const std::vector< Point > &polygon, const Projection &projection)
For a given polygon compute a reference point.
std::vector< UInt > SortedIndices(const std::vector< T > &v)
Sort a vector and return the sorted indices.
Definition Operations.hpp:154
bool IsPointInPolygonNodes(const Point &point, const std::vector< Point > &polygonNodes, const Projection &projection, Point polygonCenter={constants::missing::doubleValue, constants::missing::doubleValue}, UInt startNode=constants::missing::uintValue, UInt endNode=constants::missing::uintValue)
Checks if a point is in polygonNodes using the winding number method.
void ComputeThreeBaseComponents(const Point &point, std::array< double, 3 > &exxp, std::array< double, 3 > &eyyp, std::array< double, 3 > &ezzp)
Computes three base components.
double ComputeSquaredDistance(const Point &firstPoint, const Point &secondPoint, const Projection &projection)
Computes the squared distance between two points This is faster than ComputeDistance because it does ...
double InnerProductTwoSegments(const Point &firstPointFirstSegment, const Point &secondPointFirstSegment, const Point &firstPointSecondSegment, const Point &secondPointSecondSegment, const Projection &projection)
Inner product of two segments (dprodin)
void ResizeAndFill3DVector(std::vector< std::vector< std::vector< T > > > &v, UInt const &firstDimension, UInt const &secondDimension, UInt const &thirdDim, bool fill=false, const T &fillValue={})
Resizes and fills a three dimensional vector.
Definition Operations.hpp:74
std::vector< Point > ComputePolyLineDiscretization(std::vector< Point > const &polyline, std::vector< double > &chainages, Projection projection)
Computes the discretization points along a polyline.
Point ComputeMiddlePointAccountingForPoles(const Point &firstPoint, const Point &secondPoint, const Projection &projection)
Computes the middle point (account for poles, latitudes close to 90 degrees)
int sgn(T val)
Computes the sign of a type.
Definition Operations.hpp:543
double LinearInterpolationInTriangle(const Point &interpolationPoint, const std::vector< Point > &polygon, const std::vector< double > &values, const Projection &projection)
Given a triangles with values on each node, computes the interpolated value inside the triangle,...
UInt NextCircularBackwardIndex(UInt currentIndex, UInt size)
Get the next backward index, for a range in 0 .. size-1.
std::tuple< std::vector< double >, double > ComputeAdimensionalDistancesFromPointSerie(const std::vector< Point > &v, const Projection &projection)
Computes dimensionless distances of a vector of points such as the first entry has distance 0 and the...
UInt AbsoluteDifference(UInt number_1, UInt number_2)
Calculates the absolute difference between to Index numbers.
double NormalizedInnerProductTwoSegments(const Point &firstPointFirstSegment, const Point &secondPointFirstSegment, const Point &firstPointSecondSegment, const Point &secondPointSecondSegment, const Projection &projection)
The normalized inner product of two segments (dcosphi)
lin_alg::Matrix< Point > DiscretizeTransfinite(const std::vector< Point > &leftDiscretization, const std::vector< Point > &rightDiscretization, const std::vector< Point > &bottomDiscretization, const std::vector< Point > &upperDiscretization, const Projection &projection, UInt numM, UInt numN)
Computes the transfinite discretization inside the area defined by 4 sides, each one discretized with...
UInt FindIndex(const std::vector< T > &vec, T el)
Find index of a certain element.
Definition Operations.hpp:96
Point NormalVector(const Point &firstPoint, const Point &secondPoint, const Point &insidePoint, const Projection &projection)
Normalized vector of a segment in direction 1 -> 2 with the insidePoint orientation.
Point CircumcenterOfTriangle(const Point &firstNode, const Point &secondNode, const Point &thirdNode, const Projection &projection)
Computes the circumcenter of a triangle.
T ComputePointOnSplineAtAdimensionalDistance(const std::vector< T > &coordinates, const std::vector< T > &coordinatesDerivatives, double pointAdimensionalCoordinate)
Computes the coordinate of a point on a spline, given the dimensionless distance from the first corne...
Definition Operations.hpp:502
UInt InvalidPointCount(const std::vector< Point > &points)
Determine if the number of invalid points in the point array.
std::vector< Point > ComputeEdgeCenters(const std::vector< Point > &nodes, const std::vector< Edge > &edges)
Computes the edge centers.
bool IsPointOnPole(const Point &point)
Determines if a point is close to the poles (latitude close to 90 degrees).
std::uint32_t UInt
Integer type used when indexing mesh graph entities.
Definition Definitions.hpp:39
Point ComputeMiddlePoint(const Point &firstPoint, const Point &secondPoint, const Projection &projection)
Computes the middle point.
double ComputeDistance(const Point &firstPoint, const Point &secondPoint, const Projection &projection)
Computes the distance between two points (dbdistance)
double OuterProductTwoSegments(const Point &firstPointFirstSegment, const Point &secondPointFirstSegment, const Point &firstPointSecondSegment, const Point &secondPointSecondSegment, const Projection &projection)
Outer product of two segments (dprodout)
double FindFunctionRootWithGoldenSectionSearch(F func, double min, double max)
Algorithm performing the zero's search using the golden section algorithm's.
Definition Operations.hpp:185
double crossProduct(const Point &firstSegmentFirstPoint, const Point &firstSegmentSecondPoint, const Point &secondSegmentFirstPoint, const Point &secondSegmentSecondPoint, const Projection &projection)
Computes the cross product between two segments (duitpl)
double MatrixNorm(const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &matCoefficients)
Compute the matrix norm.
Vector ComputeNormalToline(const Point &start, const Point &end, const Projection projection)
Get the normal to the line described by the two points.
void ComputeMidPointsAndNormals(const std::vector< Point > &polygon, const std::vector< UInt > &edgesNumFaces, const UInt numNodes, std::array< Point, constants::geometric::maximumNumberOfNodesPerFace > &middlePoints, std::array< Point, constants::geometric::maximumNumberOfNodesPerFace > &normals, UInt &pointCount, const Projection &projection)
Compute mid point and normal of polygon segment.
auto ReorderVector(const std::vector< T > &v, const std::vector< UInt > &order)
Reorder vector accordingly to a specific order.
Definition Operations.hpp:168
void ResizeAndFill2DVector(std::vector< std::vector< T > > &v, UInt const &firstDimension, UInt const &secondDimension, bool fill=false, const T &fillValue={})
Resizes and fills a two dimensional vector.
Definition Operations.hpp:52
std::tuple< bool, Point, double, double, double > AreSegmentsCrossing(const Point &firstSegmentFirstPoint, const Point &firstSegmentSecondPoint, const Point &secondSegmentFirstPoint, const Point &secondSegmentSecondPoint, bool adimensionalCrossProduct, const Projection &projection)
Determines if two segments are crossing (cross, cross3D)
void TranslateSphericalCoordinates(std::vector< Point > &polygon)
For a given polygon the function may shift the input coordinates.
void ComputeTwoBaseComponents(const Point &point, double(&elambda)[3], double(&ephi)[3])
Computes two base components.
UInt CountNumberOfValidEdges(const std::vector< UInt > &edgesNumFaces, UInt numNodes)
Count the number of valid edges in list.
double GetDx(const Point &firstPoint, const Point &secondPoint, const Projection &projection)
Gets dx for the given projection.
bool IsPointInTriangle(const Point &point, const std::span< const Point > triangleNodes, const Projection &projection)
Checks if a point is in triangle using the winding number method.
std::tuple< double, Point, double > DistanceFromLine(const Point &point, const Point &firstNode, const Point &secondNode, const Projection &projection)
Computes the perpendicular distance of a point from a segment firstNode - secondNode (dlinedis3)
void NormalVectorInside(const Point &firstPoint, const Point &secondPoint, const Point &insidePoint, Point &normal, bool &flippedNormal, const Projection &projection)
Computes the normal vector to a line 1-2, which is outward w.r.t. an 'inside' point 3.
void TransformGlobalVectorToLocal(const Point &reference, const Point &globalCoordinates, const Point &globalComponents, const Projection &projection, Point &localComponents)
Transforms vector with components in global spherical coordinate directions(xglob,...
std::vector< double > ComputePolyLineEdgesLengths(std::vector< Point > const &polyline, Projection projection)
Computes the lengths of each polyline segment.
Point NormalVectorOutside(const Point &firstPoint, const Point &secondPoint, const Projection &projection)
Computes the normal vector outside (normalout)
std::vector< std::pair< UInt, UInt > > FindIndices(const std::vector< Point > &vec, size_t start, size_t end, double separator)
Find all start-end positions in a vector separated by a separator.
UInt FindPreviousIndex(const std::vector< T > &vec, UInt current)
Find the previous index in the vector, wraps around when current is the first index.
Definition Operations.hpp:123
void IncrementValidValue(UInt &value, const UInt increment)
Increment a valid value by an increment.
Definition Operations.hpp:628
std::vector< double > ComputePolyLineNodalChainages(std::vector< Point > const &polyline, Projection projection)
Computes the chainages of each polyline node.
std::tuple< Point, double, bool > OrthogonalProjectionOnSegment(Point const &firstNode, Point const &secondNode, Point const &pointToProject)
Cartesian projection of a point on a segment defined by other two points.
Point ComputeFaceCircumenter(std::vector< Point > &polygon, const std::vector< UInt > &edgesNumFaces, const Projection &projection)
Compute the circumcenter for the face described by the polygon.