1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Device/Beam/FootprintSquare.cpp
//! @brief Implements class FootprintSquare.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#include "Device/Beam/FootprintSquare.h"
#include "Base/Util/Assert.h"
#include <algorithm>
#include <cmath>
#include <numbers>
using std::numbers::pi;
FootprintSquare::FootprintSquare(const std::vector<double> P)
: IFootprint(P)
{
validateOrThrow();
}
FootprintSquare::FootprintSquare(double width_ratio)
: FootprintSquare(std::vector<double>{width_ratio})
{
}
FootprintSquare* FootprintSquare::clone() const
{
return new FootprintSquare(m_width_ratio);
}
double FootprintSquare::calculate(double alpha) const
{
ASSERT(m_validated);
if (alpha < 0.0 || alpha > (pi / 2))
return 0.0;
if (widthRatio() == 0.0)
return 1.0;
const double arg = std::sin(alpha) / widthRatio();
return std::min(arg, 1.0);
}
|