BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
PolyhedralUtil.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/Particle/PolyhedralUtil.cpp
6 //! @brief Implements interface class IFormFactor.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
16 #include "Base/Util/Algorithms.h"
17 #include "Base/Vector/RotMatrix.h"
19 #include "Sample/Shapes/IShape3D.h"
20 
21 double PolyhedralUtil::BottomZ(const std::vector<R3>& vertices, const IRotation* rotation)
22 {
23  ASSERT(vertices.size());
25  vertices.begin(), vertices.end(), [&](const R3& vertex) -> double {
26  return (rotation ? rotation->transformed(vertex) : vertex).z();
27  });
28 }
29 
30 double PolyhedralUtil::TopZ(const std::vector<R3>& vertices, const IRotation* rotation)
31 {
32  ASSERT(vertices.size());
34  vertices.begin(), vertices.end(), [&](const R3& vertex) -> double {
35  return (rotation ? rotation->transformed(vertex) : vertex).z();
36  });
37 }
Defines and implements namespace BaseUtils::algo with some algorithms.
#define ASSERT(condition)
Definition: Assert.h:45
Defines interface IShape3D.
Defines interface IDecoratableBorn.
Declares class RotMatrix.
Defines IRotation classes.
Abstract base class for rotations.
Definition: Rotations.h:29
double max_value(const Iterator &begin, const Iterator &end, const Evaluator &evaluate)
Returns the maximum value of function evaluate as applied to the elements of an iterator range.
Definition: Algorithms.h:70
double min_value(const Iterator &begin, const Iterator &end, const Evaluator &evaluate)
Returns the minimum value of function evaluate as applied to the elements of an iterator range.
Definition: Algorithms.h:58
double BottomZ(const std::vector< R3 > &vertices, const IRotation *rotation)
Calculates the z-coordinate of the lowest vertex after rotation.
double TopZ(const std::vector< R3 > &vertices, const IRotation *rotation)
Calculates the z-coordinate of the highest vertex after rotation.