BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
RotationEuler Class Reference

Description

A sequence of rotations about the z-x'-z'' axes.

Definition at line 146 of file Rotations.h.

Inheritance diagram for RotationEuler:
[legend]
Collaboration diagram for RotationEuler:
[legend]

Public Member Functions

 RotationEuler (double alpha, double beta, double gamma)
 
 RotationEuler (std::vector< double > P)
 
double alpha () const
 
double beta () const
 
void checkNodeArgs () const
 Raises exception if a parameter value is invalid. More...
 
std::string className () const final
 Returns the class name, to be hard-coded in each leaf class that inherits from INode. More...
 
RotationEulerclone () const override
 
IRotationcreateInverse () const override
 Returns a new IRotation object that is the current object's inverse. More...
 
double gamma () const
 
virtual bool isIdentity () const
 Returns true if rotation matrix is identity matrix (no rotations) More...
 
virtual std::vector< const INode * > nodeChildren () const
 Returns all children. More...
 
std::vector< const INode * > nodeOffspring () const
 Returns all descendants. More...
 
std::vector< ParaMetaparDefs () const final
 Returns the parameter definitions, to be hard-coded in each leaf class. More...
 
RotMatrix rotMatrix () const override
 Returns transformation. More...
 
virtual void transferToCPP ()
 Used for Python overriding of clone (see swig/tweaks.py) More...
 
R3 transformed (const R3 &v) const
 
bool zInvariant () const
 

Static Public Member Functions

static IRotationcreateRotation (const RotMatrix &transform)
 

Protected Attributes

double m_alpha
 
double m_beta
 
double m_gamma
 
std::vector< double > m_P
 

Constructor & Destructor Documentation

◆ RotationEuler() [1/2]

RotationEuler::RotationEuler ( std::vector< double >  P)

Definition at line 153 of file Rotations.cpp.

154  : IRotation(P)
155  , m_alpha(m_P[0])
156  , m_beta(m_P[1])
157  , m_gamma(m_P[2])
158 {
159  checkNodeArgs();
160 }
void checkNodeArgs() const
Raises exception if a parameter value is invalid.
Definition: INode.cpp:27
std::vector< double > m_P
Definition: INode.h:63
IRotation(const std::vector< double > &PValues)
Definition: Rotations.cpp:23
double m_beta
Definition: Rotations.h:169
double m_gamma
Definition: Rotations.h:169
double m_alpha
Definition: Rotations.h:169

References INode::checkNodeArgs().

Referenced by clone().

Here is the call graph for this function:

◆ RotationEuler() [2/2]

RotationEuler::RotationEuler ( double  alpha,
double  beta,
double  gamma 
)

Definition at line 162 of file Rotations.cpp.

163  : RotationEuler(std::vector<double>{alpha, beta, gamma})
164 {
165 }
double beta() const
Definition: Rotations.h:163
RotationEuler(std::vector< double > P)
Definition: Rotations.cpp:153
double gamma() const
Definition: Rotations.h:164
double alpha() const
Definition: Rotations.h:162

References alpha(), beta(), and gamma().

Here is the call graph for this function:

Member Function Documentation

◆ alpha()

double RotationEuler::alpha ( ) const
inline

Definition at line 162 of file Rotations.h.

162 { return m_alpha; }

References m_alpha.

Referenced by RotationEuler().

◆ beta()

double RotationEuler::beta ( ) const
inline

Definition at line 163 of file Rotations.h.

163 { return m_beta; }

References m_beta.

Referenced by RotationEuler().

◆ checkNodeArgs()

void INode::checkNodeArgs ( ) const
inherited

Raises exception if a parameter value is invalid.

Definition at line 27 of file INode.cpp.

28 {
29  size_t nP = m_P.size();
30  if (parDefs().size() != nP) {
31  std::cerr << "BUG in class " << className() << std::endl;
32  std::cerr << "#m_P = " << nP << std::endl;
33  std::cerr << "#PDf = " << parDefs().size() << std::endl;
34  for (const ParaMeta& pm : parDefs())
35  std::cerr << " PDf: " << pm.name << std::endl;
36  ASSERT(0);
37  }
38  ASSERT(parDefs().size() == nP);
39  for (size_t i = 0; i < nP; ++i) {
40  const ParaMeta pm = parDefs()[i];
41 
43  if (pm.vMin == -INF) {
44  ASSERT(pm.vMax == +INF);
45  // nothing to do
46  } else if (pm.vMax == +INF) {
47  ASSERT(pm.vMin == 0);
48  limits = RealLimits::nonnegative();
49  } else {
50  limits = RealLimits::limited(pm.vMin, pm.vMax);
51  }
52  limits.check(pm.name, m_P[i]);
53  }
54 }
#define ASSERT(condition)
Definition: Assert.h:45
const double INF
Definition: INode.h:26
virtual std::vector< ParaMeta > parDefs() const
Returns the parameter definitions, to be hard-coded in each leaf class.
Definition: INode.h:51
virtual std::string className() const =0
Returns the class name, to be hard-coded in each leaf class that inherits from INode.
Limits for a real fit parameter.
Definition: RealLimits.h:24
static RealLimits limitless()
Creates an object without bounds (default)
Definition: RealLimits.cpp:139
void check(const std::string &name, double value) const
Throws if value is outside limits. Parameter 'name' is for exception message.
Definition: RealLimits.cpp:170
static RealLimits nonnegative()
Creates an object which can have only positive values with 0. included.
Definition: RealLimits.cpp:124
static RealLimits limited(double left_bound_value, double right_bound_value)
Creates an object bounded from the left and right.
Definition: RealLimits.cpp:134
Metadata of one model parameter.
Definition: INode.h:29
double vMin
Definition: INode.h:33
double vMax
Definition: INode.h:34
std::string name
Definition: INode.h:30

References ASSERT, RealLimits::check(), INode::className(), INF, RealLimits::limited(), RealLimits::limitless(), INode::m_P, ParaMeta::name, RealLimits::nonnegative(), INode::parDefs(), ParaMeta::vMax, and ParaMeta::vMin.

Referenced by BarGauss::BarGauss(), BarLorentz::BarLorentz(), Bipyramid4::Bipyramid4(), Box::Box(), CantellatedCube::CantellatedCube(), Cone::Cone(), ConstantBackground::ConstantBackground(), CosineRippleBox::CosineRippleBox(), CosineRippleGauss::CosineRippleGauss(), CosineRippleLorentz::CosineRippleLorentz(), Cylinder::Cylinder(), DistributionCosine::DistributionCosine(), DistributionGate::DistributionGate(), DistributionGaussian::DistributionGaussian(), DistributionLogNormal::DistributionLogNormal(), DistributionLorentz::DistributionLorentz(), DistributionTrapezoid::DistributionTrapezoid(), Dodecahedron::Dodecahedron(), EllipsoidalCylinder::EllipsoidalCylinder(), FootprintGauss::FootprintGauss(), FootprintSquare::FootprintSquare(), FuzzySphere::FuzzySphere(), GaussSphere::GaussSphere(), HemiEllipsoid::HemiEllipsoid(), HollowSphere::HollowSphere(), HorizontalCylinder::HorizontalCylinder(), Icosahedron::Icosahedron(), LongBoxGauss::LongBoxGauss(), LongBoxLorentz::LongBoxLorentz(), PlatonicOctahedron::PlatonicOctahedron(), PlatonicTetrahedron::PlatonicTetrahedron(), Prism3::Prism3(), Prism6::Prism6(), Profile1DCauchy::Profile1DCauchy(), Profile1DCosine::Profile1DCosine(), Profile1DGate::Profile1DGate(), Profile1DGauss::Profile1DGauss(), Profile1DTriangle::Profile1DTriangle(), Profile1DVoigt::Profile1DVoigt(), Profile2DCauchy::Profile2DCauchy(), Profile2DCone::Profile2DCone(), Profile2DGate::Profile2DGate(), Profile2DGauss::Profile2DGauss(), Profile2DVoigt::Profile2DVoigt(), Pyramid2::Pyramid2(), Pyramid3::Pyramid3(), Pyramid4::Pyramid4(), Pyramid6::Pyramid6(), RotationEuler(), RotationX::RotationX(), RotationY::RotationY(), RotationZ::RotationZ(), SawtoothRippleBox::SawtoothRippleBox(), SawtoothRippleGauss::SawtoothRippleGauss(), SawtoothRippleLorentz::SawtoothRippleLorentz(), Sphere::Sphere(), Spheroid::Spheroid(), TruncatedCube::TruncatedCube(), TruncatedSphere::TruncatedSphere(), and TruncatedSpheroid::TruncatedSpheroid().

Here is the call graph for this function:

◆ className()

std::string RotationEuler::className ( ) const
inlinefinalvirtual

Returns the class name, to be hard-coded in each leaf class that inherits from INode.

Implements INode.

Definition at line 152 of file Rotations.h.

152 { return "RotationEuler"; }

◆ clone()

RotationEuler* RotationEuler::clone ( ) const
inlineoverridevirtual

Implements IRotation.

Definition at line 151 of file Rotations.h.

151 { return new RotationEuler(m_alpha, m_beta, m_gamma); }

References RotationEuler(), m_alpha, m_beta, and m_gamma.

Here is the call graph for this function:

◆ createInverse()

IRotation * RotationEuler::createInverse ( ) const
overridevirtual

Returns a new IRotation object that is the current object's inverse.

Implements IRotation.

Definition at line 167 of file Rotations.cpp.

168 {
169  RotMatrix inverse_transform(rotMatrix().Inverse());
170  return createRotation(inverse_transform);
171 }
static IRotation * createRotation(const RotMatrix &transform)
Definition: Rotations.cpp:28
Rotation matrix in three dimensions. Represents group SO(3). Internal parameterization based on quate...
Definition: RotMatrix.h:25
RotMatrix rotMatrix() const override
Returns transformation.
Definition: Rotations.cpp:173
ABObj< sym, MatrixInverse< sym, ABObj< sym, LASymMatrix, double >, double >, double > Inverse(const ABObj< sym, LASymMatrix, double > &obj)
LAPACK Algebra functions specialize the Invert function for LASymMatrix.
Definition: LaInverse.h:27

References IRotation::createRotation(), ROOT::Minuit2::Inverse(), and rotMatrix().

Here is the call graph for this function:

◆ createRotation()

IRotation * IRotation::createRotation ( const RotMatrix transform)
staticinherited

Definition at line 28 of file Rotations.cpp.

29 {
30  if (matrix.isIdentity())
31  return new IdentityRotation;
32  if (std::optional<double> angle = matrix.angleAroundCoordAxis(0))
33  return new RotationX(angle.value());
34  if (std::optional<double> angle = matrix.angleAroundCoordAxis(1))
35  return new RotationY(angle.value());
36  if (std::optional<double> angle = matrix.angleAroundCoordAxis(2))
37  return new RotationZ(angle.value());
38  auto angles = matrix.zxzEulerAngles();
39  return new RotationEuler(angles[0], angles[1], angles[2]);
40 }
The identity rotation, which leaves everything in place.
Definition: Rotations.h:58
A sequence of rotations about the z-x'-z'' axes.
Definition: Rotations.h:146
A rotation about the x axis.
Definition: Rotations.h:74
A rotation about the y axis.
Definition: Rotations.h:98
A rotation about the z axis.
Definition: Rotations.h:122

References RotMatrix::angleAroundCoordAxis(), RotMatrix::isIdentity(), and RotMatrix::zxzEulerAngles().

Referenced by ReParticle::bottomZ(), createInverse(), createProduct(), and ReParticle::topZ().

Here is the call graph for this function:

◆ gamma()

double RotationEuler::gamma ( ) const
inline

Definition at line 164 of file Rotations.h.

164 { return m_gamma; }

References m_gamma.

Referenced by RotationEuler().

◆ isIdentity()

bool IRotation::isIdentity ( ) const
virtualinherited

Returns true if rotation matrix is identity matrix (no rotations)

Reimplemented in IdentityRotation.

Definition at line 47 of file Rotations.cpp.

48 {
49  return rotMatrix().isIdentity();
50 }
virtual RotMatrix rotMatrix() const =0
Returns transformation.
bool isIdentity() const
Determine if the transformation is trivial (identity)
Definition: RotMatrix.cpp:111

References RotMatrix::isIdentity(), and IRotation::rotMatrix().

Referenced by ReParticle::createTransformedFormFactor().

Here is the call graph for this function:

◆ nodeChildren()

◆ nodeOffspring()

std::vector< const INode * > INode::nodeOffspring ( ) const
inherited

Returns all descendants.

Definition at line 61 of file INode.cpp.

62 {
63  std::vector<const INode*> result;
64  result.push_back(this);
65  for (const auto* child : nodeChildren()) {
66  for (const auto* p : child->nodeOffspring())
67  result.push_back(p);
68  }
69  return result;
70 }
virtual std::vector< const INode * > nodeChildren() const
Returns all children.
Definition: INode.cpp:56

References INode::nodeChildren().

Here is the call graph for this function:

◆ parDefs()

std::vector<ParaMeta> RotationEuler::parDefs ( ) const
inlinefinalvirtual

Returns the parameter definitions, to be hard-coded in each leaf class.

Reimplemented from INode.

Definition at line 154 of file Rotations.h.

155  {
156  return {{"Alpha", "rad", "First Euler angle, rotation around z axis", -INF, +INF, 0},
157  {"Beta", "rad", "Second Euler angle, rotation around x' axis", -INF, +INF, 0},
158  {"Gamma", "rad", "Third Euler angle, rotation around z'' axis", -INF, +INF, 0}};
159  }

References INF.

◆ rotMatrix()

RotMatrix RotationEuler::rotMatrix ( ) const
overridevirtual

Returns transformation.

Implements IRotation.

Definition at line 173 of file Rotations.cpp.

174 {
176 }
static RotMatrix EulerZXZ(double alpha, double beta, double gamma)
Creates rotation defined by Euler angles.
Definition: RotMatrix.cpp:45

References RotMatrix::EulerZXZ(), m_alpha, m_beta, and m_gamma.

Referenced by createInverse().

Here is the call graph for this function:

◆ transferToCPP()

virtual void ICloneable::transferToCPP ( )
inlinevirtualinherited

Used for Python overriding of clone (see swig/tweaks.py)

Definition at line 32 of file ICloneable.h.

◆ transformed()

R3 IRotation::transformed ( const R3 &  v) const
inherited

Definition at line 42 of file Rotations.cpp.

43 {
44  return rotMatrix().transformed(v);
45 }
T transformed(const T &v) const
Return transformed vector v.
Definition: RotMatrix.cpp:76

References IRotation::rotMatrix(), and RotMatrix::transformed().

Referenced by ReParticle::bottomZ(), Sphere::bottomZ(), IParticle::rotate(), ReParticle::topZ(), and Sphere::topZ().

Here is the call graph for this function:

◆ zInvariant()

bool IRotation::zInvariant ( ) const
inherited

Definition at line 52 of file Rotations.cpp.

53 {
54  return rotMatrix().isZRotation();
55 }
bool isZRotation() const
Definition: RotMatrix.cpp:126

References RotMatrix::isZRotation(), and IRotation::rotMatrix().

Referenced by IFormFactor::canSliceAnalytically().

Here is the call graph for this function:

Member Data Documentation

◆ m_alpha

double RotationEuler::m_alpha
protected

Definition at line 169 of file Rotations.h.

Referenced by alpha(), clone(), and rotMatrix().

◆ m_beta

double RotationEuler::m_beta
protected

Definition at line 169 of file Rotations.h.

Referenced by beta(), clone(), and rotMatrix().

◆ m_gamma

double RotationEuler::m_gamma
protected

Definition at line 169 of file Rotations.h.

Referenced by clone(), gamma(), and rotMatrix().

◆ m_P


The documentation for this class was generated from the following files: