BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
IShape.h File Reference
Include dependency graph for IShape.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  IShape
 

Functions

std::vector< kvector_tRectangleVertices (double length, double width, double z)
 
std::vector< kvector_tEllipseVertices (double r_x, double r_y, double z)
 

Detailed Description

Defines interface IShape.

Homepage:\n http://www.bornagainproject.org
License:\n GNU General Public License v3 or higher (see COPYING)
Authors
Scientific Computing Group at MLZ (see CITATION, AUTHORS)

Definition in file IShape.h.

Function Documentation

◆ RectangleVertices()

std::vector<kvector_t> RectangleVertices ( double  length,
double  width,
double  z 
)

Helper functions to construct lists of vertices.

Generate vertices of centered rectangle at height z

Definition at line 28 of file IShape.cpp.

29 {
30  std::vector<kvector_t> result = {{length / 2.0, width / 2.0, z},
31  {-length / 2.0, width / 2.0, z},
32  {-length / 2.0, -width / 2.0, z},
33  {length / 2.0, -width / 2.0, z}};
34  return result;
35 }

References anonymous_namespace{BoxCompositionBuilder.cpp}::length, and anonymous_namespace{BoxCompositionBuilder.cpp}::width.

Referenced by Box::Box().

◆ EllipseVertices()

std::vector<kvector_t> EllipseVertices ( double  r_x,
double  r_y,
double  z 
)

Generate vertices of centered ellipse with given semi-axes at height z.

Definition at line 37 of file IShape.cpp.

38 {
39  static constexpr double delta_angle = 2.0 * M_PI / IShape::N_Circle;
40  std::vector<kvector_t> result(IShape::N_Circle);
41  for (size_t i = 0; i < IShape::N_Circle; ++i) {
42  double angle = i * delta_angle;
43  double x = r_x * std::cos(angle);
44  double y = r_y * std::sin(angle);
45  result[i] = kvector_t(x, y, z);
46  }
47  return result;
48 }
#define M_PI
Definition: MathConstants.h:39
BasicVector3D< double > kvector_t
Definition: Vectors3D.h:21
static const size_t N_Circle
Definition: IShape.h:36

References M_PI, and IShape::N_Circle.

Referenced by DoubleEllipse::DoubleEllipse(), and TruncatedEllipsoid::TruncatedEllipsoid().