Mantid
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Mantid::Kernel::V2D Class Reference

Implements a 2-dimensional vector embedded in a 3D space, i.e. More...

#include <V2D.h>

Public Member Functions

double angle (const V2D &other) const
 Angle between this and another vector. More...
 
V3D cross_prod (const V2D &other) const
 Cross product. More...
 
double distance (const V2D &other) const
 Distance (R) between two points defined as vectors. More...
 
double norm () const
 Compute the norm. More...
 
double norm2 () const
 Compute the square of the norm. More...
 
double normalize ()
 Make a normalized vector (return norm value) More...
 
const double & operator[] (const size_t index) const
 Unchecked index access. More...
 
double scalar_prod (const V2D &other) const
 Compute the scalar product with another vector. More...
 
 V2D () noexcept
 Default constructor. More...
 
 V2D (double x, double y) noexcept
 Constructor taking an x and y value. More...
 
double & X ()
 X position (non-const reference) More...
 
double X () const
 X position. More...
 
double & Y ()
 Y position (non-const) More...
 
double Y () const
 Y position. More...
 
Arithmetic operations

Sum this and the rhs

V2D operator+ (const V2D &rhs) const
 
V2Doperator+= (const V2D &rhs)
 Increment this vector by rhs. More...
 
V2D operator- (const V2D &rhs) const
 Subtract rhs. More...
 
V2Doperator-= (const V2D &rhs)
 Decrement this by rhs. More...
 
V2D operator* (const double factor) const
 Scale and return. More...
 
V2Doperator*= (const double factor)
 Scale this. More...
 
V2D operator- () const noexcept
 Negate. More...
 
Comparison operators
bool operator== (const V2D &rhs) const
 Equality operator including a tolerance. More...
 
bool operator!= (const V2D &rhs) const
 Inequality operator including a tolerance. More...
 

Private Attributes

std::array< double, 2 > m_pt
 

Detailed Description

Implements a 2-dimensional vector embedded in a 3D space, i.e.

such that the cross product of two 2D vectors is a 3D vector in the Z direction

Author
Martyn Gigg, Tessella plc

Definition at line 29 of file V2D.h.

Constructor & Destructor Documentation

◆ V2D() [1/2]

Mantid::Kernel::V2D::V2D ( )
inlinenoexcept

Default constructor.

It puts the vector at the origin

Definition at line 34 of file V2D.h.

◆ V2D() [2/2]

Mantid::Kernel::V2D::V2D ( double  x,
double  y 
)
inlinenoexcept

Constructor taking an x and y value.

Definition at line 38 of file V2D.h.

References Mantid::Geometry::x, and Mantid::Geometry::y.

Member Function Documentation

◆ angle()

double Mantid::Kernel::V2D::angle ( const V2D other) const

Angle between this and another vector.

Definition at line 32 of file V2D.cpp.

References norm(), and scalar_prod().

◆ cross_prod()

V3D Mantid::Kernel::V2D::cross_prod ( const V2D other) const
inline

Cross product.

Definition at line 138 of file V2D.h.

References Mantid::Geometry::X, and Mantid::Geometry::Y.

◆ distance()

double Mantid::Kernel::V2D::distance ( const V2D other) const
inline

Distance (R) between two points defined as vectors.

Parameters
other:: A second vector
Returns
The distance between the two points

Definition at line 145 of file V2D.h.

References norm(), Mantid::Geometry::X, and Mantid::Geometry::Y.

◆ norm()

double Mantid::Kernel::V2D::norm ( ) const
inline

Compute the norm.

Returns
The norm of the vector

Definition at line 121 of file V2D.h.

Referenced by angle(), Mantid::Geometry::classify(), Mantid::Geometry::crossingPoint(), distance(), and normalize().

◆ norm2()

double Mantid::Kernel::V2D::norm2 ( ) const
inline

Compute the square of the norm.

Returns
The square of the norm

Definition at line 127 of file V2D.h.

References Mantid::Geometry::X, and Mantid::Geometry::Y.

◆ normalize()

double Mantid::Kernel::V2D::normalize ( )

Make a normalized vector (return norm value)

Returns
The norm of the vector

Definition at line 22 of file V2D.cpp.

References norm(), X(), and Y().

◆ operator!=()

bool Mantid::Kernel::V2D::operator!= ( const V2D rhs) const
inline

Inequality operator including a tolerance.

Parameters
rhs:: The rhs object
Returns
True if they are not considered equal false otherwise

Definition at line 112 of file V2D.h.

References rhs.

◆ operator*()

V2D Mantid::Kernel::V2D::operator* ( const double  factor) const
inline

Scale and return.

Definition at line 84 of file V2D.h.

References Mantid::Geometry::X, and Mantid::Geometry::Y.

◆ operator*=()

V2D & Mantid::Kernel::V2D::operator*= ( const double  factor)
inline

Scale this.

Definition at line 86 of file V2D.h.

References Mantid::Geometry::X, and Mantid::Geometry::Y.

◆ operator+()

V2D Mantid::Kernel::V2D::operator+ ( const V2D rhs) const
inline

Definition at line 68 of file V2D.h.

References rhs, Mantid::Geometry::X, and Mantid::Geometry::Y.

◆ operator+=()

V2D & Mantid::Kernel::V2D::operator+= ( const V2D rhs)
inline

Increment this vector by rhs.

Definition at line 70 of file V2D.h.

References rhs, Mantid::Geometry::X, and Mantid::Geometry::Y.

◆ operator-() [1/2]

V2D Mantid::Kernel::V2D::operator- ( ) const
inlinenoexcept

Negate.

Definition at line 92 of file V2D.h.

References Mantid::Geometry::X, and Mantid::Geometry::Y.

◆ operator-() [2/2]

V2D Mantid::Kernel::V2D::operator- ( const V2D rhs) const
inline

Subtract rhs.

Definition at line 76 of file V2D.h.

References rhs, Mantid::Geometry::X, and Mantid::Geometry::Y.

◆ operator-=()

V2D & Mantid::Kernel::V2D::operator-= ( const V2D rhs)
inline

Decrement this by rhs.

Definition at line 78 of file V2D.h.

References rhs, Mantid::Geometry::X, and Mantid::Geometry::Y.

◆ operator==()

bool Mantid::Kernel::V2D::operator== ( const V2D rhs) const
inline

Equality operator including a tolerance.

Parameters
rhs:: The rhs object
Returns
True if they are considered equal false otherwise

Definition at line 103 of file V2D.h.

References rhs, Mantid::Geometry::X, and Mantid::Geometry::Y.

◆ operator[]()

const double & Mantid::Kernel::V2D::operator[] ( const size_t  index) const
inline

Unchecked index access.

Definition at line 63 of file V2D.h.

References index.

◆ scalar_prod()

double Mantid::Kernel::V2D::scalar_prod ( const V2D other) const
inline

Compute the scalar product with another vector.

Parameters
other:: A second vector

Definition at line 133 of file V2D.h.

References Mantid::Geometry::X, and Mantid::Geometry::Y.

Referenced by angle(), and Mantid::Geometry::orientation().

◆ X() [1/2]

double & Mantid::Kernel::V2D::X ( )
inline

X position (non-const reference)

Returns
The X position

Definition at line 55 of file V2D.h.

◆ X() [2/2]

double Mantid::Kernel::V2D::X ( ) const
inline

◆ Y() [1/2]

double & Mantid::Kernel::V2D::Y ( )
inline

Y position (non-const)

Returns
The Y position

Definition at line 60 of file V2D.h.

◆ Y() [2/2]

double Mantid::Kernel::V2D::Y ( ) const
inline

Member Data Documentation

◆ m_pt

std::array<double, 2> Mantid::Kernel::V2D::m_pt
private

Definition at line 152 of file V2D.h.


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