OGS
Utils.cpp
Go to the documentation of this file.
1
12#include "Utils.h"
13
14#include "BaseLib/Error.h"
15
16namespace GeoLib
17{
18std::vector<GeoLib::Point*> generateEquidistantPoints(
19 MathLib::Point3d const& begin, MathLib::Point3d const& end,
20 int const number_of_subdivisions)
21{
22 if (number_of_subdivisions < 0)
23 {
25 "generateEquidistantPoints: number of subdivisions is required to "
26 "be non-negative.");
27 }
28
29 auto const& start = begin.asEigenVector3d();
30 auto const& stop = end.asEigenVector3d();
31 auto const delta = (stop - start) / (number_of_subdivisions + 1);
32
33 std::vector<GeoLib::Point*> points;
34
35 for (int i = 0; i <= number_of_subdivisions; ++i)
36 {
37 auto const p = start + i * delta;
38 points.push_back(new GeoLib::Point{p[0], p[1], p[2]});
39 }
40 points.push_back(new GeoLib::Point{stop[0], stop[1], stop[2]});
41
42 return points;
43}
44
45} // namespace GeoLib
#define OGS_FATAL(...)
Definition: Error.h:26
Eigen::Vector3d const & asEigenVector3d() const
Definition: Point3d.h:67
std::vector< GeoLib::Point * > generateEquidistantPoints(MathLib::Point3d const &begin, MathLib::Point3d const &end, int const number_of_subdivisions)
Definition: Utils.cpp:18