BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
FormFactorPrism3.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Sample/HardParticle/FormFactorPrism3.cpp
6 //! @brief Implements class FormFactorPrism3.
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 <iostream>
17 
18 FormFactorPrism3::FormFactorPrism3(const std::vector<double> P)
19  : IFormFactorPrism({"Prism3",
20  "prism with regular trigonal base",
21  {{"BaseEdge", "nm", "edge length of trigonal base", 0, +INF, 0},
22  {"Height", "nm", "height", 0, +INF, 0}}},
23  P),
24  m_base_edge(m_P[0]), m_height(m_P[1])
25 {
26  onChange();
27 }
28 
29 FormFactorPrism3::FormFactorPrism3(double base_edge, double height)
30  : FormFactorPrism3(std::vector<double>{base_edge, height})
31 {
32 }
33 
35  kvector_t translation) const
36 {
37  auto effects = computeSlicingEffects(limits, translation, m_height);
38  FormFactorPrism3 slicedff(m_base_edge, m_height - effects.dz_bottom - effects.dz_top);
39  return createTransformedFormFactor(slicedff, rot, effects.position);
40 }
41 
43 {
44  double a = m_base_edge;
45  double as = a / 2;
46  double ac = a / sqrt(3) / 2;
47  double ah = a / sqrt(3);
48  std::vector<kvector_t> V{{-ac, as, 0.}, {-ac, -as, 0.}, {ah, 0., 0.}};
49  setPrism(false, V);
50 }
Defines class FormFactorPrism3.
IFormFactor * createTransformedFormFactor(const IFormFactor &formfactor, const IRotation &rot, kvector_t translation)
Definition: IFormFactor.cpp:77
const double INF
Definition: INode.h:24
A prism based on an equilateral triangle.
FormFactorPrism3(const std::vector< double > P)
void onChange() override final
Action to be taken in inherited class when a parameter has changed.
const double & m_height
IFormFactor * sliceFormFactor(ZLimits limits, const IRotation &rot, kvector_t translation) const override final
Actually slices the form factor or throws an exception.
double height() const final
const double & m_base_edge
SlicingEffects computeSlicingEffects(ZLimits limits, const kvector_t &position, double height) const
Helper method for slicing.
A prism with a polygonal base, for form factor computation.
void setPrism(bool symmetry_Ci, const std::vector< kvector_t > &vertices)
Pure virtual base class for all form factors.
Definition: IFormFactor.h:40
Pure virtual interface for rotations.
Definition: Rotations.h:27
Class that contains upper and lower limits of the z-coordinate for the slicing of form factors.
Definition: ZLimits.h:41