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

Public Member Functions

 Ellipse (double xcenter, double ycenter, double xradius, double yradius, double theta=0.0)
 
Ellipseclone () const
 
bool contains (double x, double y) const
 
bool contains (const Bin1D &binx, const Bin1D &biny) const
 
double getCenterX () const
 
double getCenterY () const
 
double getRadiusX () const
 
double getRadiusY () const
 
double getTheta () const
 
virtual void transferToCPP ()
 

Protected Member Functions

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

Private Attributes

double m_xc
 
double m_yc
 
double m_xr
 
double m_yr
 
double m_theta
 
const char *const m_name
 

Detailed Description

Ellipse shape.

Definition at line 23 of file Ellipse.h.

Constructor & Destructor Documentation

◆ Ellipse()

Ellipse::Ellipse ( double  xcenter,
double  ycenter,
double  xradius,
double  yradius,
double  theta = 0.0 
)
Parameters
xcenterx-coordinate of Ellipse's center
ycentery-coordinate of Ellipse's center
xradiusRadius along x-axis
yradiusRadius along y-axis
thetaAngle of Ellipse rotation in radians

Definition at line 24 of file Ellipse.cpp.

25  : IShape2D("Ellipse"), m_xc(xcenter), m_yc(ycenter), m_xr(xradius), m_yr(yradius),
26  m_theta(theta)
27 {
28  if (xradius <= 0.0 || yradius <= 0.0)
30  "Ellipse::Ellipse(double xcenter, double ycenter, double xradius, double yradius) "
31  "-> Error. Radius can't be negative\n");
32 }
double m_xc
Definition: Ellipse.h:39
double m_xr
Definition: Ellipse.h:39
double m_yc
Definition: Ellipse.h:39
double m_yr
Definition: Ellipse.h:39
double m_theta
Definition: Ellipse.h:39
IShape2D(const char *name)
Definition: IShape2D.h:29

Referenced by clone().

Member Function Documentation

◆ clone()

Ellipse* Ellipse::clone ( ) const
inlinevirtual

Implements IShape2D.

Definition at line 27 of file Ellipse.h.

27 { return new Ellipse(m_xc, m_yc, m_xr, m_yr, m_theta); }
Ellipse(double xcenter, double ycenter, double xradius, double yradius, double theta=0.0)
Definition: Ellipse.cpp:24

References Ellipse(), m_theta, m_xc, m_xr, m_yc, and m_yr.

Here is the call graph for this function:

◆ contains() [1/2]

bool Ellipse::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 34 of file Ellipse.cpp.

35 {
36  double u = std::cos(m_theta) * (x - m_xc) + std::sin(m_theta) * (y - m_yc);
37  double v = -std::sin(m_theta) * (x - m_xc) + std::cos(m_theta) * (y - m_yc);
38  double d = (u / m_xr) * (u / m_xr) + (v / m_yr) * (v / m_yr);
39  return d <= 1;
40 }

References m_theta, m_xc, m_xr, m_yc, and m_yr.

Referenced by contains().

◆ contains() [2/2]

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

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

Implements IShape2D.

Definition at line 44 of file Ellipse.cpp.

45 {
46  return contains(binx.getMidPoint(), biny.getMidPoint());
47 }
bool contains(double x, double y) const
Returns true if point with given coordinates is inside or on border of the shape.
Definition: Ellipse.cpp:34
double getMidPoint() const
Definition: Bin.h:25

References contains(), and Bin1D::getMidPoint().

Here is the call graph for this function:

◆ getCenterX()

double Ellipse::getCenterX ( ) const
inline

Definition at line 32 of file Ellipse.h.

32 { return m_xc; }

References m_xc.

◆ getCenterY()

double Ellipse::getCenterY ( ) const
inline

Definition at line 33 of file Ellipse.h.

33 { return m_yc; }

References m_yc.

◆ getRadiusX()

double Ellipse::getRadiusX ( ) const
inline

Definition at line 34 of file Ellipse.h.

34 { return m_xr; }

References m_xr.

◆ getRadiusY()

double Ellipse::getRadiusY ( ) const
inline

Definition at line 35 of file Ellipse.h.

35 { return m_yr; }

References m_yr.

◆ getTheta()

double Ellipse::getTheta ( ) const
inline

Definition at line 36 of file Ellipse.h.

36 { return m_theta; }

References m_theta.

◆ 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_xc

double Ellipse::m_xc
private

Definition at line 39 of file Ellipse.h.

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

◆ m_yc

double Ellipse::m_yc
private

Definition at line 39 of file Ellipse.h.

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

◆ m_xr

double Ellipse::m_xr
private

Definition at line 39 of file Ellipse.h.

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

◆ m_yr

double Ellipse::m_yr
private

Definition at line 39 of file Ellipse.h.

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

◆ m_theta

double Ellipse::m_theta
private

Definition at line 39 of file Ellipse.h.

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

◆ 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: