BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
RectangularPixel Class Reference
Inheritance diagram for RectangularPixel:
Collaboration diagram for RectangularPixel:

Public Member Functions

 RectangularPixel (kvector_t corner_pos, kvector_t width, kvector_t height)
 
RectangularPixelclone () const override
 
RectangularPixelcreateZeroSizePixel (double x, double y) const override
 
kvector_t getK (double x, double y, double wavelength) const override
 
kvector_t getPosition (double x, double y) const
 
double getIntegrationFactor (double x, double y) const override
 
double getSolidAngle () const override
 

Private Member Functions

kvector_t normalizeLength (const kvector_t direction, double length) const
 
double calculateSolidAngle () const
 

Private Attributes

kvector_t m_corner_pos
 
kvector_t m_width
 
kvector_t m_height
 
double m_solid_angle
 
kvector_t m_normal
 

Detailed Description

A pixel in a RectangularDetector.

Definition at line 22 of file RectangularPixel.h.

Constructor & Destructor Documentation

◆ RectangularPixel()

RectangularPixel::RectangularPixel ( kvector_t  corner_pos,
kvector_t  width,
kvector_t  height 
)

Definition at line 23 of file RectangularPixel.cpp.

24  : m_corner_pos(std::move(corner_pos)), m_width(std::move(width)), m_height(std::move(height))
25 {
27  auto solid_angle_value = calculateSolidAngle();
28  m_solid_angle = solid_angle_value <= 0.0 ? 1.0 : solid_angle_value;
29 }
auto cross(const BasicVector3D< U > &v) const
Returns cross product of vectors (linear in both arguments).
double calculateSolidAngle() const
kvector_t m_corner_pos

References calculateSolidAngle(), BasicVector3D< T >::cross(), m_height, m_normal, m_solid_angle, and m_width.

Referenced by clone(), and createZeroSizePixel().

Here is the call graph for this function:

Member Function Documentation

◆ clone()

RectangularPixel * RectangularPixel::clone ( ) const
overridevirtual

Implements IPixel.

Definition at line 31 of file RectangularPixel.cpp.

32 {
34 }
RectangularPixel(kvector_t corner_pos, kvector_t width, kvector_t height)

References m_corner_pos, m_height, m_width, and RectangularPixel().

Here is the call graph for this function:

◆ createZeroSizePixel()

RectangularPixel * RectangularPixel::createZeroSizePixel ( double  x,
double  y 
) const
overridevirtual

Implements IPixel.

Definition at line 36 of file RectangularPixel.cpp.

37 {
38  return new RectangularPixel(getPosition(x, y), kvector_t(), kvector_t());
39 }
BasicVector3D< double > kvector_t
Definition: Vectors3D.h:21
kvector_t getPosition(double x, double y) const

References getPosition(), and RectangularPixel().

Here is the call graph for this function:

◆ getK()

kvector_t RectangularPixel::getK ( double  x,
double  y,
double  wavelength 
) const
overridevirtual

Implements IPixel.

Definition at line 41 of file RectangularPixel.cpp.

42 {
43  kvector_t direction = getPosition(x, y);
44  double length = M_TWOPI / wavelength;
45  return normalizeLength(direction, length);
46 }
#define M_TWOPI
Definition: MathConstants.h:49
kvector_t normalizeLength(const kvector_t direction, double length) const

References getPosition(), anonymous_namespace{BoxCompositionBuilder.cpp}::length, M_TWOPI, normalizeLength(), and anonymous_namespace{SlicedCylindersBuilder.cpp}::wavelength().

Here is the call graph for this function:

◆ getPosition()

kvector_t RectangularPixel::getPosition ( double  x,
double  y 
) const

Definition at line 48 of file RectangularPixel.cpp.

49 {
50  return m_corner_pos + x * m_width + y * m_height;
51 }

References m_corner_pos, m_height, and m_width.

Referenced by calculateSolidAngle(), createZeroSizePixel(), getIntegrationFactor(), and getK().

◆ getIntegrationFactor()

double RectangularPixel::getIntegrationFactor ( double  x,
double  y 
) const
overridevirtual

Implements IPixel.

Definition at line 53 of file RectangularPixel.cpp.

54 {
55  if (m_solid_angle == 0.0)
56  return 1.0;
57  kvector_t position = getPosition(x, y);
58  double length = position.mag();
59  return std::abs(position.dot(m_normal)) / std::pow(length, 3) / m_solid_angle;
60 }
auto dot(const BasicVector3D< U > &v) const
Returns dot product of vectors (antilinear in the first [=self] argument).
double mag() const
Returns magnitude of the vector.

References BasicVector3D< T >::dot(), getPosition(), anonymous_namespace{BoxCompositionBuilder.cpp}::length, m_normal, m_solid_angle, and BasicVector3D< T >::mag().

Here is the call graph for this function:

◆ getSolidAngle()

double RectangularPixel::getSolidAngle ( ) const
overridevirtual

Implements IPixel.

Definition at line 62 of file RectangularPixel.cpp.

63 {
64  return m_solid_angle;
65 }

References m_solid_angle.

◆ normalizeLength()

kvector_t RectangularPixel::normalizeLength ( const kvector_t  direction,
double  length 
) const
private

Definition at line 67 of file RectangularPixel.cpp.

68 {
69  return direction.unit() * length;
70 }
BasicVector3D< T > unit() const
Returns unit vector in direction of this. Throws for null vector.

References anonymous_namespace{BoxCompositionBuilder.cpp}::length, and BasicVector3D< T >::unit().

Referenced by getK().

Here is the call graph for this function:

◆ calculateSolidAngle()

double RectangularPixel::calculateSolidAngle ( ) const
private

Definition at line 72 of file RectangularPixel.cpp.

73 {
74  kvector_t position = getPosition(0.5, 0.5);
75  double length = position.mag();
76  return std::abs(position.dot(m_normal)) / std::pow(length, 3);
77 }

References BasicVector3D< T >::dot(), getPosition(), anonymous_namespace{BoxCompositionBuilder.cpp}::length, m_normal, and BasicVector3D< T >::mag().

Referenced by RectangularPixel().

Here is the call graph for this function:

Member Data Documentation

◆ m_corner_pos

kvector_t RectangularPixel::m_corner_pos
private

Definition at line 37 of file RectangularPixel.h.

Referenced by clone(), and getPosition().

◆ m_width

kvector_t RectangularPixel::m_width
private

Definition at line 38 of file RectangularPixel.h.

Referenced by clone(), getPosition(), and RectangularPixel().

◆ m_height

kvector_t RectangularPixel::m_height
private

Definition at line 39 of file RectangularPixel.h.

Referenced by clone(), getPosition(), and RectangularPixel().

◆ m_solid_angle

double RectangularPixel::m_solid_angle
private

Definition at line 40 of file RectangularPixel.h.

Referenced by getIntegrationFactor(), getSolidAngle(), and RectangularPixel().

◆ m_normal

kvector_t RectangularPixel::m_normal
private

Definition at line 41 of file RectangularPixel.h.

Referenced by calculateSolidAngle(), getIntegrationFactor(), and RectangularPixel().


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