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

Sum this and the rhs

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

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 145 of file V2D.h.

◆ 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 152 of file V2D.h.

References norm().

◆ norm()

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

Compute the norm.

Returns
The norm of the vector

Definition at line 128 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 134 of file V2D.h.

◆ 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 119 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.

◆ operator*=()

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

Scale this.

Definition at line 86 of file V2D.h.

◆ operator+()

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

Definition at line 68 of file V2D.h.

References rhs.

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

◆ operator-() [1/2]

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

Negate.

Definition at line 99 of file V2D.h.

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

◆ operator-=()

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

Decrement this by rhs.

Definition at line 78 of file V2D.h.

References rhs.

◆ operator/()

V2D Mantid::Kernel::V2D::operator/ ( const double  d) const
inlinenoexcept

Divide by d.

Definition at line 92 of file V2D.h.

References Mantid::Geometry::d.

◆ operator/=()

V2D & Mantid::Kernel::V2D::operator/= ( const double  d)
inline

Definition at line 93 of file V2D.h.

References Mantid::Geometry::d.

◆ 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 110 of file V2D.h.

References rhs.

◆ 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 140 of file V2D.h.

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 159 of file V2D.h.


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