BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
IShape3D.h File Reference

Defines interface IShape3D. More...

Include dependency graph for IShape3D.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  IShape3D
 Abstract base class for different shapes. More...
 

Macros

#define BORNAGAIN_SAMPLE_SHAPES_ISHAPE_H
 

Functions

std::vector< kvector_tEllipseVertices (double r_x, double r_y, double z)
 Generate vertices of centered ellipse with given semi-axes at height z. More...
 
std::vector< kvector_tRectangleVertices (double length, double width, double z)
 Helper functions to construct lists of vertices. More...
 

Detailed Description

Defines interface IShape3D.

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 IShape3D.h.

Macro Definition Documentation

◆ BORNAGAIN_SAMPLE_SHAPES_ISHAPE_H

#define BORNAGAIN_SAMPLE_SHAPES_ISHAPE_H

Definition at line 21 of file IShape3D.h.

Function Documentation

◆ 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 IShape3D.cpp.

38 {
39  static constexpr double delta_angle = 2.0 * M_PI / IShape3D::N_Circle;
40  std::vector<kvector_t> result(IShape3D::N_Circle);
41  for (size_t i = 0; i < IShape3D::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: Constants.h:44
BasicVector3D< double > kvector_t
Definition: Vectors3D.h:21
static const size_t N_Circle
Definition: IShape3D.h:40

References M_PI, and IShape3D::N_Circle.

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

◆ 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 IShape3D.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 }

Referenced by Box::Box().