Mantid
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Mantid::Geometry::Quadrilateral Class Referencefinal

A ConvexPolygon with only 4 vertices. More...

#include <Quadrilateral.h>

Inheritance diagram for Mantid::Geometry::Quadrilateral:
Mantid::Geometry::ConvexPolygon

Public Member Functions

double area () const override
 Compute the area of the polygon using triangulation. More...
 
const Kernel::V2Dat (const size_t index) const override
 Bounds-checked index access. More...
 
bool contains (const ConvexPolygon &poly) const override
 Is a the given polygon completely encosed by this one. More...
 
bool contains (const Kernel::V2D &point) const override
 Is a point inside this polygon. More...
 
double determinant () const override
 Compute the determinant of the set of points as if they were contained in an (N+1)x(N+1) matrix where N=number of vertices. More...
 
double maxX () const override
 Return the max X value in the polygon. More...
 
double maxY () const override
 Return the max Y value in the polygon. More...
 
double minX () const override
 Return the lowest X value in the polygon. More...
 
double minY () const override
 Return the lowest Y value in the polygon. More...
 
size_t npoints () const override
 Return the number of vertices. More...
 
Quadrilateraloperator= (const Quadrilateral &)=default
 
Quadrilateraloperator= (Quadrilateral &&)=default
 
const Kernel::V2Doperator[] (const size_t index) const override
 Index access. More...
 
 Quadrilateral (const double lowerX, const double upperX, const double lowerY, const double upperY)
 Special constructor for a rectangle. More...
 
 Quadrilateral (const Kernel::V2D &lowerLeft, const Kernel::V2D &lowerRight, const Kernel::V2D &upperRight, const Kernel::V2D &upperLeft)
 Constructor with the four vertices. More...
 
 Quadrilateral (const Quadrilateral &)=default
 
 Quadrilateral (Quadrilateral &&)=default
 
virtual void shiftVertexesClockwise ()
 Shifts the vertexes in a clockwise manner. More...
 
ConvexPolygon toPoly () const override
 Return a new Polygon based on the current Quadrilateral. More...
 
- Public Member Functions inherited from Mantid::Geometry::ConvexPolygon
virtual double area () const
 Compute the area of the polygon using triangulation. More...
 
virtual const Kernel::V2Dat (const size_t index) const
 Bounds-checked index access. More...
 
void clear ()
 Clears all points. More...
 
virtual bool contains (const ConvexPolygon &poly) const
 Is a the given polygon completely encosed by this one. More...
 
virtual bool contains (const Kernel::V2D &point) const
 Is a point inside this polygon. More...
 
 ConvexPolygon ()
 Default constructor. More...
 
 ConvexPolygon (const ConvexPolygon &)=default
 
 ConvexPolygon (ConvexPolygon &&)=default
 
 ConvexPolygon (Vertices vertices)
 Construct a polygon from a collection of points. More...
 
virtual double determinant () const
 Compute the 'determinant' of the points. More...
 
void insert (const Kernel::V2D &pt)
 Insert a new vertex. More...
 
void insert (double x, double y)
 Insert a new vertex based on x,y values. More...
 
bool isValid () const
 Check if polygon is valid. More...
 
virtual double maxX () const
 Return the largest X value in the polygon. More...
 
virtual double maxY () const
 Return the largest Y value in the polygon. More...
 
virtual double minX () const
 Return the lowest X value in the polygon. More...
 
virtual double minY () const
 Return the lowest Y value in the polygon. More...
 
virtual size_t npoints () const
 Return the number of vertices. More...
 
ConvexPolygonoperator= (const ConvexPolygon &)=default
 
ConvexPolygonoperator= (ConvexPolygon &&)=default
 
virtual const Kernel::V2Doperator[] (const size_t index) const
 Index access. More...
 
virtual ConvexPolygon toPoly () const
 Return a new Polygon based on the current type. More...
 
virtual ~ConvexPolygon ()=default
 Destructor. More...
 

Private Member Functions

const Kernel::V2DlowerLeft () const
 
const Kernel::V2DlowerRight () const
 
const Kernel::V2DupperLeft () const
 
const Kernel::V2DupperRight () const
 

Private Attributes

std::array< Kernel::V2D, 4 > m_vertices
 

Additional Inherited Members

- Public Types inherited from Mantid::Geometry::ConvexPolygon
using Vertices = std::vector< Kernel::V2D >
 Type of the point list. More...
 

Detailed Description

A ConvexPolygon with only 4 vertices.

Better performance as no dynamic allocation

Definition at line 24 of file Quadrilateral.h.

Constructor & Destructor Documentation

◆ Quadrilateral() [1/4]

Mantid::Geometry::Quadrilateral::Quadrilateral ( const Kernel::V2D lowerLeft,
const Kernel::V2D lowerRight,
const Kernel::V2D upperRight,
const Kernel::V2D upperLeft 
)

Constructor with the four vertices.

Constructor.

Definition at line 19 of file Quadrilateral.cpp.

References lowerLeft(), lowerRight(), upperLeft(), and upperRight().

◆ Quadrilateral() [2/4]

Mantid::Geometry::Quadrilateral::Quadrilateral ( const double  lowerX,
const double  upperX,
const double  lowerY,
const double  upperY 
)

Special constructor for a rectangle.

Definition at line 25 of file Quadrilateral.cpp.

◆ Quadrilateral() [3/4]

Mantid::Geometry::Quadrilateral::Quadrilateral ( Quadrilateral &&  )
default

◆ Quadrilateral() [4/4]

Mantid::Geometry::Quadrilateral::Quadrilateral ( const Quadrilateral )
default

Member Function Documentation

◆ area()

double Mantid::Geometry::Quadrilateral::area ( ) const
inlineoverridevirtual

Compute the area of the polygon using triangulation.

As this is a convex polygon the calculation is exact. The algorithm uses one vertex as a common vertex and sums the areas of the triangles formed by this and two other vertices, moving in an anti-clockwise direction.

Returns
The area of the polygon

Reimplemented from Mantid::Geometry::ConvexPolygon.

Definition at line 53 of file Quadrilateral.h.

References rhs, Mantid::Kernel::V2D::X(), and Mantid::Kernel::V2D::Y().

Referenced by Mantid::DataObjects::FractionalRebinning::rebinToFractionalOutput(), and Mantid::DataObjects::FractionalRebinning::rebinToOutput().

◆ at()

const Kernel::V2D & Mantid::Geometry::Quadrilateral::at ( const size_t  index) const
overridevirtual

Bounds-checked index access.

Return the vertex at the given index.

Parameters
index:: An index, starting at 0
Returns
A reference to the polygon at that index
Exceptions
Exception::IndexErrorif the index is out of range

Reimplemented from Mantid::Geometry::ConvexPolygon.

Definition at line 35 of file Quadrilateral.cpp.

References index, and npoints().

Referenced by Mantid::DataObjects::CalculateReflectometryKiKf::createQuad(), Mantid::DataObjects::CalculateReflectometryP::createQuad(), and Mantid::DataObjects::CalculateReflectometryQxQz::createQuad().

◆ contains() [1/2]

bool Mantid::Geometry::Quadrilateral::contains ( const ConvexPolygon poly) const
overridevirtual

Is a the given polygon completely encosed by this one.

Returns
True if the given polygon is completely encosed by this one

Reimplemented from Mantid::Geometry::ConvexPolygon.

Definition at line 52 of file Quadrilateral.cpp.

References Mantid::Geometry::ConvexPolygon::contains(), and toPoly().

◆ contains() [2/2]

bool Mantid::Geometry::Quadrilateral::contains ( const Kernel::V2D point) const
overridevirtual

Is a point inside this polygon.

Returns
True if the point is inside the polygon or on the edge

Reimplemented from Mantid::Geometry::ConvexPolygon.

Definition at line 44 of file Quadrilateral.cpp.

References Mantid::Geometry::ConvexPolygon::contains(), and toPoly().

◆ determinant()

double Mantid::Geometry::Quadrilateral::determinant ( ) const
inlineoverridevirtual

Compute the determinant of the set of points as if they were contained in an (N+1)x(N+1) matrix where N=number of vertices.

Each row contains the [X,Y] values of the vertex padded with zeroes to the column length.

Returns
The determinant of the set of points

Reimplemented from Mantid::Geometry::ConvexPolygon.

Definition at line 67 of file Quadrilateral.h.

◆ lowerLeft()

const Kernel::V2D & Mantid::Geometry::Quadrilateral::lowerLeft ( ) const
inlineprivate

Definition at line 82 of file Quadrilateral.h.

Referenced by Quadrilateral(), and toPoly().

◆ lowerRight()

const Kernel::V2D & Mantid::Geometry::Quadrilateral::lowerRight ( ) const
inlineprivate

Definition at line 85 of file Quadrilateral.h.

Referenced by Quadrilateral(), and toPoly().

◆ maxX()

double Mantid::Geometry::Quadrilateral::maxX ( ) const
inlineoverridevirtual

◆ maxY()

double Mantid::Geometry::Quadrilateral::maxY ( ) const
inlineoverridevirtual

◆ minX()

double Mantid::Geometry::Quadrilateral::minX ( ) const
inlineoverridevirtual

◆ minY()

double Mantid::Geometry::Quadrilateral::minY ( ) const
inlineoverridevirtual

◆ npoints()

size_t Mantid::Geometry::Quadrilateral::npoints ( ) const
inlineoverridevirtual

Return the number of vertices.

Reimplemented from Mantid::Geometry::ConvexPolygon.

Definition at line 41 of file Quadrilateral.h.

Referenced by at().

◆ operator=() [1/2]

Quadrilateral & Mantid::Geometry::Quadrilateral::operator= ( const Quadrilateral )
default

◆ operator=() [2/2]

Quadrilateral & Mantid::Geometry::Quadrilateral::operator= ( Quadrilateral &&  )
default

◆ operator[]()

const Kernel::V2D & Mantid::Geometry::Quadrilateral::operator[] ( const size_t  index) const
inlineoverridevirtual

Index access.

Reimplemented from Mantid::Geometry::ConvexPolygon.

Definition at line 37 of file Quadrilateral.h.

References index.

◆ shiftVertexesClockwise()

void Mantid::Geometry::Quadrilateral::shiftVertexesClockwise ( )
virtual

◆ toPoly()

ConvexPolygon Mantid::Geometry::Quadrilateral::toPoly ( ) const
overridevirtual

Return a new Polygon based on the current Quadrilateral.

Returns
A new polygon based on the current Quadrilateral

Reimplemented from Mantid::Geometry::ConvexPolygon.

Definition at line 58 of file Quadrilateral.cpp.

References Mantid::Geometry::ConvexPolygon::ConvexPolygon(), lowerLeft(), lowerRight(), upperLeft(), and upperRight().

Referenced by contains().

◆ upperLeft()

const Kernel::V2D & Mantid::Geometry::Quadrilateral::upperLeft ( ) const
inlineprivate

Definition at line 83 of file Quadrilateral.h.

Referenced by Quadrilateral(), and toPoly().

◆ upperRight()

const Kernel::V2D & Mantid::Geometry::Quadrilateral::upperRight ( ) const
inlineprivate

Definition at line 84 of file Quadrilateral.h.

Referenced by Quadrilateral(), and toPoly().

Member Data Documentation

◆ m_vertices

std::array<Kernel::V2D, 4> Mantid::Geometry::Quadrilateral::m_vertices
private

Definition at line 88 of file Quadrilateral.h.

Referenced by shiftVertexesClockwise().


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