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

Public Member Functions

 HorizontalLine (double y)
 
HorizontalLineclone () const
 
bool contains (double x, double y) const
 
bool contains (const Bin1D &binx, const Bin1D &biny) const
 
double getYpos () const
 
virtual void transferToCPP ()
 

Protected Member Functions

virtual void print (std::ostream &ostr) const
 

Private Attributes

double m_y
 
const char *const m_name
 

Detailed Description

An infinite horizontal line.

Definition at line 57 of file Line.h.

Constructor & Destructor Documentation

◆ HorizontalLine()

HorizontalLine::HorizontalLine ( double  y)
Parameters
yThe value at which it crosses y-axes

Definition at line 83 of file Line.cpp.

83 : IShape2D("HorizontalLine"), m_y(y) {}
double m_y
Definition: Line.h:69
IShape2D(const char *name)
Definition: IShape2D.h:29

Referenced by clone().

Member Function Documentation

◆ clone()

HorizontalLine* HorizontalLine::clone ( ) const
inlinevirtual

Implements IShape2D.

Definition at line 61 of file Line.h.

61 { return new HorizontalLine(m_y); }
HorizontalLine(double y)
Definition: Line.cpp:83

References HorizontalLine(), and m_y.

Here is the call graph for this function:

◆ contains() [1/2]

bool HorizontalLine::contains ( double  x,
double  y 
) const
virtual

Returns true if point with given coordinates is inside or on border of the shape.

Implements IShape2D.

Definition at line 85 of file Line.cpp.

86 {
87  return algo::almostEqual(y, m_y);
88 }
bool almostEqual(double a, double b)
Returns true if two doubles agree within machine epsilon.
Definition: Algorithms.h:30

References algo::almostEqual(), and m_y.

Here is the call graph for this function:

◆ contains() [2/2]

bool HorizontalLine::contains ( const Bin1D binx,
const Bin1D biny 
) const
virtual

Returns true if area defined by two bins is inside or on border of polygon (more precisely, if mid point of two bins satisfy this condition).

Implements IShape2D.

Definition at line 90 of file Line.cpp.

91 {
92  return m_y >= biny.m_lower && m_y <= biny.m_upper;
93 }
double m_upper
upper bound of the bin
Definition: Bin.h:24
double m_lower
lower bound of the bin
Definition: Bin.h:23

References Bin1D::m_lower, Bin1D::m_upper, and m_y.

◆ getYpos()

double HorizontalLine::getYpos ( ) const
inline

Definition at line 66 of file Line.h.

66 { return m_y; }

References m_y.

◆ print()

virtual void IShape2D::print ( std::ostream &  ostr) const
inlineprotectedvirtualinherited

Reimplemented in Polygon.

Definition at line 46 of file IShape2D.h.

46 { ostr << m_name; }
const char *const m_name
Definition: IShape2D.h:49

References IShape2D::m_name.

◆ transferToCPP()

virtual void ICloneable::transferToCPP ( )
inlinevirtualinherited

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

Definition at line 34 of file ICloneable.h.

Member Data Documentation

◆ m_y

double HorizontalLine::m_y
private

Definition at line 69 of file Line.h.

Referenced by clone(), contains(), and getYpos().

◆ m_name

const char* const IShape2D::m_name
privateinherited

Definition at line 49 of file IShape2D.h.

Referenced by IShape2D::print().


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