OGS
GeoLib/Utils.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#include "Utils.h"
5
6#include "BaseLib/Error.h"
7
8namespace GeoLib
9{
10std::vector<GeoLib::Point*> generateEquidistantPoints(
11 MathLib::Point3d const& begin, MathLib::Point3d const& end,
12 int const number_of_subdivisions)
13{
14 if (number_of_subdivisions < 0)
15 {
17 "generateEquidistantPoints: number of subdivisions is required to "
18 "be non-negative.");
19 }
20
21 auto const& start = begin.asEigenVector3d();
22 auto const& stop = end.asEigenVector3d();
23 auto const delta = (stop - start) / (number_of_subdivisions + 1);
24
25 std::vector<GeoLib::Point*> points;
26
27 for (int i = 0; i <= number_of_subdivisions; ++i)
28 {
29 auto const p = start + i * delta;
30 points.push_back(new GeoLib::Point{p[0], p[1], p[2]});
31 }
32 points.push_back(new GeoLib::Point{stop[0], stop[1], stop[2]});
33
34 return points;
35}
36
37} // namespace GeoLib
#define OGS_FATAL(...)
Definition Error.h:19
Eigen::Vector3d const & asEigenVector3d() const
Definition Point3d.h:55
std::vector< GeoLib::Point * > generateEquidistantPoints(MathLib::Point3d const &begin, MathLib::Point3d const &end, int const number_of_subdivisions)